为什么这封邮件不发送任何邮件?(或任何调试的想法?)
在my_app/config/environments/development.rb中我有这样的代码:
config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'my_app.com', user_name: ENV['GMAIL_USERNAME'], password: ENV['GMAIL_PASSWORD'], authentication: 'plain', enable_starttls_auto: true }
然后在〜/ .bash_profile的本地计算机上我有这个代码:
export GMAIL_USERNAME='blah@my_app.com' export GMAIL_PASSWORD='***'
当我$ env
在终端中运行时,我看到两个环境变量都已正确设置.
我也重新启动了我的rails服务器.
如果您在从控制台发送电子邮件时遇到问题,则必须在邮件上调用发送方法.
MyMailer.create_email.deliver
对于没有使用smtp的人,将交付方法切换到sendmail除了明确设置要执行的交付之外,还帮助我:
config.action_mailer.delivery_method = :sendmail
你应该添加
config.action_mailer.perform_deliveries = true
默认情况下,这是假的,防止从您的开发环境发送邮件...