2014-09-29 124 views
0

因此,我的项目之一有一个SMTP服务器已配置为使用没有任何形式的身份验证。这是我在config/environments/production.rb上的SMTP设置。Rails ActionMailer发送电子邮件没有身份验证

config.action_mailer.asset_host = 'http://example.com' 
config.action_mailer.default_url_options = { host: 'example.com' } 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.raise_delivery_errors = true 
config.action_mailer.smtp_settings = { 
    address:    'mail.example.com', 
    port:    587, 
    domain:    'info.example.com', 
    user_name:   '[email protected]', 
    password:    '', 
    openssl_verify_mode: 'none', 
    authentication:  nil, 
    tls:     false, 
    enable_starttls_auto: false 
} 

我虽然authentication模式需要被设置为nil,但是,当我试图发送电子邮件,它给了我这个错误。

2.0.0-p481 :001 > CustomerMailer.test.deliver 
Net::SMTPAuthenticationError: 503 5.5.1 Error: authentication not enabled 

任何解决方案,家伙?

回答

3

您正在指定验证详细信息。 ActionMailer会相应地使用它们。

解决方法:不要。

config.action_mailer.smtp_settings = { 
    address: 'mail.example.com', 
    port: 587, 
    domain: 'info.example.com' 
} 

(该domain参数可以根据自身您的服务器配置是不必要的。)

+0

它给我'引发ArgumentError:SMTP-AUTH请求但缺少秘密phrase'错误。 – 2014-09-29 06:53:27

+0

好的。它现在有效。谢谢。 :) – 2014-10-01 12:17:15

相关问题