Using encrypted connection with ActionMailer

Hello Folks,

I am trying to use Gmail to send out test emails from my dev machine. I have the following in my environment.rb

ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = {   :address => "",   :port => 465,   :domain => "",   :authentication => :login,   :user_name => "myloginid",   :password => "mypassword" }

I can see in my log file that the email is being prepped for sending. However after a little while I get a timeout error as below. My Outlook settings for email have the flag checked for "This server requires an encrypted connection (SSL)". Do I need to set something in my smtp_settings? I also see some error about `method_missing' in action_mailer/base.rb in the error below but not sure what that is about.

Anything else I need to do to get this to work?

Thanks for your help. Sanjay.

c:/ruby/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill' c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout' c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout' c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill' c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline' c:/ruby/lib/ruby/1.8/net/smtp.rb:664:in `recv_response' c:/ruby/lib/ruby/1.8/net/smtp.rb:396:in `do_start' c:/ruby/lib/ruby/1.8/net/smtp.rb:686:in `critical' c:/ruby/lib/ruby/1.8/net/smtp.rb:396:in `do_start' c:/ruby/lib/ruby/1.8/net/smtp.rb:378:in `start' c:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/ base.rb:565:in `perform_delivery_smtp' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/ base.rb:451:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/ base.rb:451:in `deliver!' c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/ base.rb:333:in `method_missing' #{RAILS_ROOT}/app/controllers/email_controller.rb:9:in `remind'

Hi skt,

I'm having the same problem. As I found, google uses TSL (SSL) sou you'll need to use this plugin ( actionmailer-tls). I think it patches ruby NET:SMTP. The link for it appears to be dead so I put it in Just unzip it in vendors\plugins

Unfortunatelly, I tried this plugin and it didn't work for me, but you should try. In this link ( integration), you'll find another action, using a intermediary smtp server.

When using another e-mail without SSL, the e-mail was sent without problems.

With the plugin maybe you should try changing your config:   :authentication => :login, to :authentication => :plain,

If it works for you, please let me know.

Hello again,

Now it's working! I even found another way.

First change your port from '465' to '587' (I was using 465 also, and it didnt work)

So, if you use the action_mailer_optional_tls plugin your config should be:

ActionMailer::Base.smtp_settings = { :address => '', :port => 587, :domain => '', :authentication => :plain, :user_name => '', # i think it should work without the domal :password => 'pass', :tls => true }

The other option is using the tlsmail gem (It also worked for me):

The last option I read about was changing ryby 1.8.x smtp.rb for ruby 1.9 smtp.rb (which supports tsl). That didn't worked for me, and I think isn't a good idea.


Thanks Hugo. I didn't check this thread after a few days thinking no one was going to reply. Appreciate the info. I too figured out that using a different port and an smtp_tls file I got from a site helped make it work though it is rather slow.

Thanks for your feedback - in case you happen to look at this thread again.