繁体   English   中英

Rails ActionMailer发送没有身份验证的电子邮件

[英]Rails ActionMailer Send Email Without Authentication

因此,我的一个项目有一个SMTP服务器,该服务器已配置为在没有任何形式的身份验证的情况下使用。 这是我在config/environments/production.rb上的SMTP设置。

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:            'no-reply@example.com',
    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

伙计们?

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

解决方案:不要。

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

(根据您的服务器配置, domain参数本身可能是不必要的。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM