我使用Yandex Connect (SMTP)作为从我的Rails 5 JSON API应用程序发送电子邮件的方法。
下面是设置:
Rails.application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'smtp.yandex.com',
port: 25,
domain: ENV['MAIL_DOMAIN'],
user_name: ENV['MAIL_USER'],
password: ENV['MAIL_PASSWORD'],
authentication: 'plain',
enable_starttls_auto: true
}
end
我的application.rb
中也设置了config.action_mailer.default_url_options = { host: ENV['MAIL_DOMAIN'] }
在heroku上,只要有正确的凭据,它就能正常工作。但是,当我尝试在本地运行相同的配置并发送电子邮件时,我得到了ArgumentError - SMTP-AUTH requested but missing secret phrase
。
会出什么问题呢?
发布于 2018-02-07 17:28:33
1)确保环境变量确实存在,例如bundle exec rails console
、puts ENV.inspect
2)确保凭证无误
3)修改环境后重启开发服务器。这包括spring stop
。
https://stackoverflow.com/questions/48650303
复制相似问题