0
votes

I'm trying to configure Zoho mail smtp and i don't understand what do i do wrong. In development mode everything is ok but in production i have the error below when i send email:

Net::SMTPAuthenticationError: 530 5.5.1 Authentication Required.

My production env settings:

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: 'not-real.com' }

config.action_mailer.smtp_settings = {
  port: 465,
  ssl: true,
  tls: true,
  authentication: :login,
  address: 'smtp.zoho.eu',
  domain: 'not-real.com',
  enable_starttls_auto: true,
  password:  ENV['ZOHO_PASSWORD'],
  user_name: ENV['ZOHO_USER_NAME']
}

First at all i thought the problem in wrong password or user_name but not. Next i checked domain in Zoho Control Panel ---> Domains but everything is ok. In Zoho SMTP Server Configuration says:

 Outgoing Server Name: smtp.zoho.eu
 Port: 465
 Security Type: SSL 

 Require Authentication: Yes. 

But could you please tell me what does this mean? -> Require Authentication: Yes.

Should i change something in Zoho settings?

2
Solved!. Actually the problem was in setting env variables through .bashrc file in production. So when i was checking the env variables in rails console by Rails.application.config.action_mailer.smtp_settings all options were present and correctly but email didn't work. I solved it by using dotenv-rails in my production instead of .bashrc file. Here the link i'm using to setup .env in production stackoverflow.com/questions/17150736/…Sasha Stadnik

2 Answers

0
votes
config.action_mailer.delivery_method = :smtp

config.action_mailer.default_url_options = { host: 'example.com' }

config.action_mailer.smtp_settings = {
    port: 587,
    ssl: true,
    tls: true,
    authentication: :login,
    address: 'smtp.zoho.com',
    domain: 'mail.zoho.com',
    enable_starttls_auto: true,
    password:  'password',
    user_name: 'username'
}

That worked for me. Your settings might be fine some local networks block these kinds of packets.

0
votes

In Your production.rb at the end of the file add :

ActionMailer::Base.smtp_settings = {  
  :address              => 'smtp.zoho.com',  
  :port                 => 587, # change to 465 if using ssl 
  :domain               => 'zoho.com', # if you have no domain  
  :user_name            => '[email protected]',  
  :password             => 'YourPassword',  
  :authentication       => 'plain',  # change to ssl or tls as required
  :enable_starttls_auto => true,
  :openssl_verify_mode => 'none'
}
  • Add the same code above to your setup_mail.rb file.