I want to send email via my gmail account in PRODUCTION. It works great in local host.
我想通过PRODUCTION中的gmail帐户发送电子邮件。它在本地主机上运行良好。
In my environment.rb I have :
在我的环境中.rb我有:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "myhost.com",
:authentication => "plain",
:user_name => "name@myhost.com",
:password => "mypassword",
:enable_starttls_auto => true
}
And in my production.rb file :
在我的production.rb文件中:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'gmail.com' }
But it doesn't work and I have that error :
但它没有用,我有这个错误:
Errno::ECONNREFUSED (Connection refused - connect(2)):
Any ideas ? My app is deployed on Heroku. For the host
what do I have to put ?
有任何想法吗 ?我的应用程序部署在Heroku上。对于主持人我需要放什么?
Thanks !
1 个解决方案
#1
2
Host should be www.yourapp.com
. My settings for gmail on Heroku look like this, and they work:
主持人应该是www.yourapp.com。我在Heroku上设置gmail的设置如下所示,它们的工作原理如下:
config.action_mailer.default_url_options = { :host => 'www.myapp.com' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "user@myapp.com",
:password => "mypassword"
}
#1
2
Host should be www.yourapp.com
. My settings for gmail on Heroku look like this, and they work:
主持人应该是www.yourapp.com。我在Heroku上设置gmail的设置如下所示,它们的工作原理如下:
config.action_mailer.default_url_options = { :host => 'www.myapp.com' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "user@myapp.com",
:password => "mypassword"
}