此问题已经多次提出,答案是需要使用有效的电子邮件地址(SENDER)来发送来自Rails应用的电子邮件。但是,我仍然收到此错误。这是我的生产配置
ActionMailer::Base.default :from => 'mypersonalemailaddress@gmail.com'
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'https://peaceful-cove-8372.herokuapp.com'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { :host => 'https://www.myapp.org' }
我指定了自己的个人电子邮件地址,但仍然出现此错误。我想我没有理解这是如何运作的。我应该补充一点,我的开发配置使用这个电子邮件地址工作得很好。有什么想法吗?
工作日志错误是:
ResponseWorker JID-f1abef7152aca07b829ac16c DEBUG: Failure! Retry 1 in 64 seconds
2015-07-27T16:21:02.377105+00:00 app[worker.1]: 3 TID-ov5xeb7p0
WARN: {"class"=>"ResponseWorker", "args"=>[71], "retry"=>5, "queue"=>"default",
"jid"=>"f1abef7152aca07b829ac16c", "created_at"=>1438014039.1775503,
"enqueued_at"=>1438014061.402422, "error_message"=>"An SMTP To address
is required to send a message. Set the message smtp_envelope_to, to, cc,
or bcc address.", "error_class"=>"ArgumentError",
"failed_at"=>1438014040.0273588, "retry_count"=>1, "retried_at"=>1438014062.3470724}
以下是我的MicropostMailer中的方法示例
def notify_question_followers_of_response(micropost, response, follower)
@response = response
@micropost = micropost
@email = follower.email
@follower = follower
@notification = follower.notification
mail to: @email, subject: "#{@response.user.full_name} wrote an answer to a question you follow: \"#{@micropost.content}\""
end
我在这里看不到问题......当然,我还是比较新的。我不明白为什么它在开发中工作得很好而不是在生产中....