Using encrypted connection with ActionMailer

43 views
Skip to first unread message

skt

unread,
Jan 25, 2008, 8:01:59 PM1/25/08
to Ruby on Rails: Talk
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",
:port => 465,
:domain => "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'

hugo....@gmail.com

unread,
Jan 31, 2008, 10:49:31 PM1/31/08
to Ruby on Rails: Talk
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-
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.
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-
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.

hugo....@gmail.com

unread,
Feb 1, 2008, 8:10:44 AM2/1/08
to Ruby on Rails: Talk
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',
:port => 587,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => 'na...@gmail.com', # 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

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, "hugo.bor...@gmail.com" <hugo.bor...@gmail.com>
wrote:
> 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-
> actionmailer-tls). I think it patches ruby NET:SMTP. The link for it
> appears to be dead so I put it inhttp://www.yamaa.com.br/action_mailer_optional_tls.zip.

skt

unread,
Mar 10, 2008, 8:09:43 PM3/10/08
to Ruby on Rails: Talk
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, "hugo.bor...@gmail.com" <hugo.bor...@gmail.com>
wrote:
> 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',
> :port => 587,
> :domain => 'gmail.com',
> :authentication => :plain,
> :user_name => 'n...@gmail.com', # 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-action...
>
> 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, "hugo.bor...@gmail.com" <hugo.bor...@gmail.com>
> wrote:
>
> > Hiskt,
>
> > 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-
> > actionmailer-tls). I think it patches ruby NET:SMTP. The link for it
> > appears to be dead so I put it inhttp://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-
> > 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.
>
Reply all
Reply to author
Forward
0 new messages