ActionMailer 在开发 Rails 4 中不发送邮件 [英] ActionMailer not sending mail in development Rails 4
本文介绍了ActionMailer 在开发 Rails 4 中不发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这个邮件程序不发送任何邮件?(或者任何调试的想法?)
Why is this mailer not sending any mail? (Or any ideas for debugging?)
在 my_app/config/environments/development.rb 我有这个代码:
In my_app/config/environments/development.rb I have this code:
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 我有这个代码:
Then on my local computer in ~/.bash_profile I have this code:
export GMAIL_USERNAME='blah@my_app.com'
export GMAIL_PASSWORD='***'
当我在终端中运行 $ env
时,我看到两个环境变量都已正确设置.
When I run $ env
in my terminal, I see that both environment variables are correctly set.
我也重新启动了我的 rails 服务器.
I have also restarted my rails server.
推荐答案
你应该添加
config.action_mailer.perform_deliveries = true
默认情况下这是错误的,防止从您的开发环境发送邮件...
as by default this is on false, preventing mails to be sent from your development environment...
这篇关于ActionMailer 在开发 Rails 4 中不发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文