我在config/environments/production.rb
使用Heroku + SendGrid時,是否需要提供「發件人」電子郵件地址?
config.action_mailer.default_url_options = { host: "myapp.heroku.com" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:addresses => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
然而,標準的設置,我遇到了以下錯誤嘗試發送郵件:
ArgumentError: An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.
然後我用我在我的Heroku上的郵箱嘗試附加頁,即app######@heroku.com
,但現在我得到了
Errno::ECONNREFUSED: Connection refused - connect(2)
那麼我需要從郵件中指定一個嗎?如果是的話,我應該使用哪一個?
你的意思是我要註冊一個Gmail帳戶,並使用它作爲電子郵件的例子嗎?但如果是這樣,那我該如何提供gmail用戶名和密碼? – Heisenberg