# Using encrypted connection with ActionMailer

**URL:** <https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199>\
**Category:** Rails\
**Created:** [January 26, 2008, 2:02am UTC](https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199 "2008-01-26T02:02:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [January 26, 2008, 2:02am UTC](https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199/1 "2008-01-26T02:02:57Z")

</div>

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 =\> “[smtp.gmail.com](http://smtp.gmail.com)”,  
:port =\> 465,  
:domain =\> “[mydomain.com](http://mydomain.com)”,  
: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’

---

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [February 1, 2008, 4:50am UTC](https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199/2 "2008-02-01T04:50:20Z")

</div>

Hi skt,

I’m having the same problem. As I found, google uses TSL (SSL) sou  
you’ll need to use this plugin ([http://www.railslodge.com/plugins/449-](http://www.railslodge.com/plugins/449-)  
actionmailer-tls). I think it patches ruby NET:SMTP. The link for it  
appears to be dead so I put it in  
[http://www.yamaa.com.br/action\_mailer\_optional\_tls.zip](http://www.yamaa.com.br/action_mailer_optional_tls.zip).  
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 ([http://www.depixelate.com/2007/2/2/rails-and-google-apps-](http://www.depixelate.com/2007/2/2/rails-and-google-apps-)  
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.

---

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [March 11, 2008, 1:10am UTC](https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199/3 "2008-03-11T01:10:25Z")

</div>

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.

-S

On Feb 1, 6:10 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![skt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@skt](https://www.ruby-forum.com/u/skt)\
**Post date:** [February 1, 2008, 2:11pm UTC](https://www.ruby-forum.com/t/using-encrypted-connection-with-actionmailer/127199/4 "2008-02-01T14:11:32Z")

</div>

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 =\> ‘[smtp.gmail.com](http://smtp.gmail.com)’,  
:port =\> 587,  
:domain =\> ‘[gmail.com](http://gmail.com)’,  
:authentication =\> :plain,  
:user\_name =\> ‘removed\_email\_address@domain.invalid’, # 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):

[http://www.wanlord.com/articles/2007/11/29/sending-email-using-actionmailer-and-gmail](http://www.wanlord.com/articles/2007/11/29/sending-email-using-actionmailer-and-gmail)

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.

Bye

On Feb 1, 1:49 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
