来自SMTP服务器的Rails响应 [英] Response from SMTP server with Rails
问题描述
当我使用 Mailer.deliver
方法发送电子邮件时,如何使用ActionMailer从Ruby on Rails中的SMTP服务器获得响应?
How could I get the response from an SMTP server in Ruby on Rails using ActionMailer, when I send an email with the Mailer.deliver
method?
我找到了 Actionmailer SMTP服务器响应的答案,但它不起作用...知道吗?
I found the Actionmailer SMTP Server Response answer but it doesn't work... Any idea?
我需要它,因为 AWS SES通过返回消息ID ,这是将消息链接到他们随后提供的退信或垃圾邮件报告的唯一方法。 / p>
I need it because AWS SES return a message ID through, and it's the only way to get the message linked to a bounce or spam report they provide after.
推荐答案
如果您以这种方式获取smtp
if you get the smtp in way like this
response = Mail.your_mail().deliver
得到您需要的响应,请尝试delivery_now!
and it isn't getting the response that you need, try deliver_now!
response = Mail.your_mail().deliver_now!
pp response.message
这将向您显示结果:250 2.0.0好的:排队为3lG8S16Khmz6ZhXq
This will show you the result: 250 2.0.0 Ok: queued as 3lG8S16Khmz6ZhXq
我还在Mail.rb上配置了smtp设置。
I also configured the smtp settings on my Mail.rb
delivery_options = { user_name: 'email@server.com.br',
password: 'mypassword',
authentication: :login,
address: 'smtp.mycompany.com.br',
port: 2525,
domain: 'mycompany.com.br',
return_response: true
}
这篇关于来自SMTP服务器的Rails响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!