ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to , cc, or bcc address

泪湿孤枕 提交于 2019-12-03 09:37:12

The error message is not about the SMTP envelope, but about the sender:

An SMTP To address is required to send a message

the rest is just a generic message. Something in your testmail@mymailaddress.com is not working. Do you use a real, working address? If not, try with one.

If you use sidekiq+actionmailer. Be careful, while sending email using hash. I was doing something like this MyWorker.perform_async("var1", {email: 'test@test.com', var2: 'test1234'})

I banged my head for couple of hours, why it is throwing the above error. Because in the perform_menthod hash[:email] is nil. You need to use hash["email"] to receive the email. I do not know, the reason. But it helped me to get rid of this error.

Is :to => 'testmail@mymailaddress.com' how it is in your failing environment? If it's not a hardcoded email address, do make sure that a variable containing the to-address is not blank.

You don't have to set Mail::Message#smtp_envelope_to explicitly. It can guess it from its recipients, ie. Mail::Message#destinations (to + cc + bcc), but it doesn't seem to have any.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!