Monday, November 17, 2008

ActionMailer with Gmail. Must issue a STARTTLS command first

If you ever tried sending e-mail via ActionMailer with gmail settings you may have received the following error:

530 5.7.0 Must issue a STARTTLS command first. k41sm7289021rvb.4

The problem is that Gmail requires TLS authentication but the standard Ruby net/smtp library doesn't support TLS.

Of course there is a helpful plugin created by Marc Chung to overcome this barrier. You can find it here and manually add it to your project or you can export it to your plugin directory.

$ cd vendor/plugins
$ svn export http://code.openrain.com/rails/action_mailer_tls/

Either way make sure you require 'smtp_tls'

Now all you need is to update your smtp_settings if you haven't done so already.


ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.com",
:user_name => "user@domain.com",
:password => "password",
:authentication => :plain
}

You can now enjoy the benefits of a free email server.

7 comments:

Mohamed Jamal said...

Thanks for the article. However, I'm still a little confused. Shouldn't the domain and password be gmail.com and valid gmail account, respectively? Or does this refer to something else?

Mohamed Jamal said...

I believe http://code.openrain.com is no longer available. Do you have the URL to the new location?

Francisco Riveros Escobar said...

http://github.com/openrain/action_mailer_tls

that is the new url of the plugin ;)
best Regards

www.4minds.cl

Anonymous said...

miley cyrus nude miley cyrus nude miley cyrus nude

Anonymous said...

Divorce Records Birth records by state

cialis online said...

cialis online

Anonymous said...

Free Arrest Records Search