2017-08-04 101 views
0

我想配置Zoho的邮件的SMTP,我不明白我该怎么办错了。在发展模式一切正常,但在生产中我有,当我发送电子邮件以下错误:Rails的百会网:: SMTPAuthenticationError:530

Net::SMTPAuthenticationError: 530 5.5.1 Authentication Required. 

我生产ENV设置:

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

首先,在所有我想在错误的密码或USER_NAME问题但不是。接下来,我在Zoho控制面板--->域中检查了域名,但一切都很好。在Zoho SMTP服务器配置说:

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

Require Authentication: Yes. 

但是,请问您能告诉我这是什么意思? - >需要验证:是。

我应该改变在百会设置什么?

+0

解决!实际上,问题在于通过生产环境中的.bashrc文件设置env变量。所以,当我通过Rails.application.config.action_mailer.smtp_settings检查rails控制台中的env变量时,所有选项都存在且正确,但电子邮件无法正常工作。我通过在我的制作中使用dotenv-rails而不是.bashrc文件来解决此问题。在这里,我使用的链接设置.ENV生产https://stackoverflow.com/questions/17150736/environment-variables-on-production –

回答

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

这对我有效。一些本地网络阻止了这些类型的数据包,你的设置可能没有问题

+0

现在我有这个错误:OpenSSL的:: SSL :: SSLError:所以SSL_connect返回= 1 errno = 0 state = SSLv2/v3读取服务器hello A:未知协议。这是因为使用smtp.zoho.eu.这就是为什么我使用端口:465 –

+0

删除tls和使用端口:465并尝试一次。我没有任何错误。它在我的生产中工作正常。 – Pravanthi

+0

其实我已经尝试了很多选择,它不起作用。与这些设置相同:端口:465,ssl:true,域:'mail.zoho.com',身份验证::登录,地址:'smtp.zoho.com',enable_starttls_auto:true,密码:ENV ['ZOHO_PASSWORD' ],user_name:ENV ['ZOHO_USER_NAME']现在我有Net :: SMTPAuthenticationError:535身份验证失败 –