Inspired? No home

SMTP error while using Gmail in Rails

To use Gmail as a SMTP server in Rails I used the required smtp_tls code as described on Railstips. Worked great on my development machine (OS X with Ruby 1.8.6) but on my slicehost server (Ubuntu 8.10 with Ruby 1.8.7) i got the following error:

ERROR ArgumentError: wrong number of arguments (3 for 2) FILE config/initializers/smtp_tls.rb, line 8

Asked Google. Tried updating everything. Tried using a lower version of Rails. Asked Google again. Nothing worked. Asked Google again the next day and the following turned up on a RedMine forum:

removing authtype from the call to check_auth_args on line 33 of vendor/plugins/action_mailer_optional_tls/lib/smtp_tls.rb fixes the problem. Looks like a bug in action_mailer_optional_tls rather than redmine. Looks like Net::SMTP changed the function signature for check_auth_args. Bad programmer - no red bull for you.

So change this:

#check_auth_args user, secret, authtype if user or secret
if RUBY_VERSION > "1.8.6"
  check_auth_args user, secret # for rails 1.8.7
else
  check_auth_args user, secret, authtype if user or secret # for rails 1.8.6
end

The solution is quite obvious considering the error message but as it worked locally I figured something else was wrong.

Works great. Next task: Uninstall postfix on Ubuntu. Need to get rid of what I can on a 256 mb server.

Written on 13 December 2008.
blog comments powered by Disqus