依照catz的
gmail設定這篇設定gmail,在localhost也測試OK,但是丟上heroku後卻壞掉(得到「Must issue a STARTTLS command first」錯誤)
後來找到了
這篇文章,他說可能是heroku的lib太舊,所以依照指示:
1. 下載
tls_smtp.rb. (在
這篇找到的)
2. 放到app的lib資料夾
3. 引入到 config/environment.rb
複製內容到剪貼板
代碼:
require 'tls_smtp'然後上傳到heroku,完成了!
我沒有依照
這篇所說要再增加mailer設定到config/environments/production.rb,不過他還是成功。
這是我的mailer設定 (我放在 config/initializers/mail.rb) (就是用catz那篇的設定):
複製內容到剪貼板
代碼:
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => 'xxxxxx@gmail.com',
:password => '******'
}希望這篇有幫助
(
也有發佈在我的blog上)