Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails ActionMailer configuration for Zoho

Anyone have luck configuring ActionMailer to send email via a Zoho account?

These are my settings:

ActionMailer::Base.smtp_settings = {
    :address              => "smtp.zoho.com",
    :port                 => 465,
    :domain               => 'example.com',
    :user_name            => '[email protected]',
    :password             => 'n0tmypa$$w0rd',
    :authentication       => :login
}

However, calling .deliver times out:

irb(main):001:0> AdminMailer.signup_notification('asfd').deliver
Timeout::Error: Timeout::Error
        from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
        from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
        from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
        from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
        from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
        from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start'
        from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
        from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start'
        from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'

The help docs say to use port 465 and SSL authentication. I've tried with and without :enable_starttls_auto => true but it still times out.

Specifically, the docs specify the following settings:

>     Email Address: [email protected]
>     User Name format: [email protected]
>     Secure Connection (SSL)   Yes
>     Outgoing Mail Server Name: smtp.zoho.com
>     Outgoing Port No.: 465
>     Outgoing Mail Server requires authentication: Yes

Any ideas?

p.s. I've configured Outlook to use the settings in the help docs and outgoing email works fine. telnet to smtp.zoho.com 465 also connects.

like image 500
lambinator Avatar asked Dec 12 '12 07:12

lambinator


2 Answers

# Action Mailer
ActionMailer::Base.delivery_method = :smtp  
ActionMailer::Base.smtp_settings = {            
  :address              => "smtp.zoho.com", 
  :port                 => 465,                 
  :user_name            => '[email protected]',
  :password             => 'password',         
  :authentication       => :login,
  :ssl                  => true,
  :tls                  => true,
  :enable_starttls_auto => true    
}

That worked for me. Your settings might be fine some local networks block these kinds of packets. I had to test it through my 3G network.

like image 75
Tyrel Richey Avatar answered Oct 16 '22 16:10

Tyrel Richey


FYI:

Let's say your domain is abc.com.
Let's say you have 'default from' on your mailer with a different domain, e.g.

  default from: "\"Elephant\" <[email protected]>"

This will not work unless you change your 'default from' using the same domain on your zoho account.
So,

  default from: "\"Elephant\" <[email protected]>"

will work.

like image 24
stefano salvucci Avatar answered Oct 16 '22 16:10

stefano salvucci