使用相同的config / application.rb(见下文),我可以使用一个Gmail帐户发送,但不能发送第二个Gmail帐户。第二个Gmail帐户是首选,我使用浏览器验证了登录凭据,并确保它接受“安全性较低的应用”。
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
user_name: 'accountname',
password: 'secret',
authentication: 'plain',
enable_starttls_auto: true
同样使用第二个Gmail,我在生产中遇到了NET :: SMTPAUthenticationError,它只是在没有抱怨的情况下不会在开发模式下发送。
最后,我使用的是Rails控制台,我的目标是使用rake任务来发送电子邮件,而不是在Web环境中。