Actionmailer SMTP服务器响应 [英] Actionmailer SMTP Server Response
问题描述
通过actionmailer发送邮件时,在SMTP服务器正常或错误时,该动作邮件将从SMTP服务器获得响应。发送邮件后是否有办法检索此响应?
当SMTP服务器没有抛出任何错误时吗?
When sending mail through actionmailer, the actionmailer gets a response from the SMTP server, when its ok, or when its wrong. Is there a way to retrieve this response after sending a mail? Also when no errors are thrown by the SMTP server?
我们的qmail邮件服务器会抛出一个处理程序ID,我们希望该ID用于跟踪电子邮件。
Our qmail mail server throws a handler id which we want to use for tracing e-mails.
例如,服务器响应如下:
As an example, the server response is this :
250 ok 1308235825 qp 17832
250 ok 1308235825 qp 17832
推荐答案
在smtp设置中设置 return_response:true
并调用 message .deliver!
而不是 deliver
。这将返回SMTP服务器响应,即 Net :: SMTP :: Response
,其中包含您要查找的服务器响应。
Set return_response: true
in the smtp settings and call message.deliver!
instead of deliver
. This returns the SMTP server response, a Net::SMTP::Response
, which contains the server response you're looking for.
如果需要与服务器连接的所有响应的日志,而不仅仅是最终结果,则需要深入研究Net :: SMTP。
If you need a log of all responses from the connection with the server, not just the final result, you'll need to dig into Net::SMTP.
这篇关于Actionmailer SMTP服务器响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!