Rails Zoho Net::SMTPAuthenticationError: 530

时间:2017-08-04 13:10:12

标签: ruby-on-rails-5 actionmailer zoho

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 个答案:

答案 0 :(得分:0)

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'
}

这对我有用。您的设置可能很好,一些本地网络阻止这些类型的数据包。

答案 1 :(得分:0)

在文件末尾的production.rb中添加:

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            => 'YourUsername@zoho.com',  
  :password             => 'YourPassword',  
  :authentication       => 'plain',  # change to ssl or tls as required
  :enable_starttls_auto => true,
  :openssl_verify_mode => 'none'
}
  • 将上述相同代码添加到setup_mail.rb文件中。