Question

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            => 'steve@example.com',
    :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: Username@yourdomain.com
>     User Name format: Username@yourdomain.com
>     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.

Was it helpful?

Solution

# Action Mailer
ActionMailer::Base.delivery_method = :smtp  
ActionMailer::Base.smtp_settings = {            
  :address              => "smtp.zoho.com", 
  :port                 => 465,                 
  :user_name            => 'someone@somewhere.com',
  :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.

OTHER TIPS

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\" <el@ephant.com>"

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

  default from: "\"Elephant\" <el@abc.com>"

will work.

I'm not sure if Zoho have changed their security settings, but @Tyrel Richey's accepted answer didn't work for me. However, the following does:

/config/initializers/action_mailer.rb..

# ActionMailer email configuration
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address              => ENV['SMTP_ADDRESS'],
  :port                 => ENV['SMTP_PORT'],
  :domain               => ENV['SMTP_DOMAIN'],
  :user_name            => ENV['SMTP_USERNAME'],
  :password             => ENV['SMTP_PASSWORD'],
  :authentication       => :login,
  :enable_starttls_auto => true
}

Where..
:address = smtp.zoho.com
:port = 587
:domain is localhost in development, and the live URL in production (e.g. example.com)

I have mail sending with Rails 4.2.3 like so...

# config/environments/development.rb
Rails.application.configure do
#...
  config.action_mailer.default_url_options = { host: 'domain' }
  config.action_mailer.smtp_settings = { address: 'smtp.zoho.com', port: 465, user_name: 'username@domain.com', password: 'mypassword', authentication: :login, ssl: true }
end

You can of course use this in production as well by adding this to config/environments/production.rb

I also set the email address in config/initializers/devise.rb so I can send password reset instruction.

config.mailer_sender = 'noreply@truhawk.com'


References

These settings worked for me in production.

Rails.application.routes.default_url_options[:host] = 'eyehawk.io'
  config.action_mailer.default_url_options = { :host => 'eyehawk.io' }
  config.action_mailer.perform_caching = false

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
      :address              => "smtp.zoho.com",
      :port                 => 587,
      :domain               => "zoho.com",
      :user_name            => "admin@eyehawk.io",
      :password             => ENV['SMTP_PASSWORD'],
      :authentication       => :plain,
      :enable_starttls_auto => true
  }

Using smtp.zoho.eu instead of smtp.zoho.com as address did the trick for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top