使用phpmailer,当您执行 - > send()
时,似乎没有将任何类型的“信息”发送回,除了true/fals:https://phpmailer.github.io/PHPMailer/classes/PHPMailer-PHPMailer-PHPMailer.html#method_send
发送电子邮件时,我正在尝试立即从服务器中获取“消息ID”。我需要此功能才能输入我的数据库以跟踪传出电子邮件。
是的,当我从IMAP服务器中获取实际发送的电子邮件时,我将记录插入数据库中,但是我需要知道消息ID是什么,以便我可以自动验证它已被发送和Whotot,而不是必须始终查看我的电子邮件客户端的“已发送”文件夹,以确保其实际发送(因此被以“已发送”电子邮件获取)。
如果这没有意义,那么至少知道我需要“跟踪”它,但是除非有错误,否则phpmailer似乎不会发送任何类型的信息。
与phpmailer发送电子邮件时,如何立即获取消息ID?
With PHPMailer, when you do ->send()
, it appears to not send any kind of "information" back except true/false: https://phpmailer.github.io/PHPMailer/classes/PHPMailer-PHPMailer-PHPMailer.html#method_send
I'm trying to get the "Message-Id" immediately back from the server when I send the e-mail. I need this in order to enter into my database to track the outgoing e-mails.
Yes, I insert the records into my database when I fetch the actually sent e-mails from the IMAP server, but I need to know what the Message-Id is so that I can verify automatically that it has been sent and whatnot, and not have to always look in my "sent" folder of my e-mail client to make sure it was actually sent (and thus fetched as a "sent" e-mail).
If this doesn't make sense, then at least know that I need to "track" it, but PHPMailer doesn't appear to send back any kind of information unless there is an error.
How do I get the Message-Id immediately when sending an e-mail with PHPMailer?
发布评论
评论(1)
此问题的机制与消息ID无关的。在查看邮件服务器日志时知道,与客户端的每次交互都会标记为从初始连接到交付,这是有用的,实际消息ID并非如此。
您将在
$ aim-> lastMessageId
中找到实际消息ID,我建议通过$ air-&gtlastMessageId()
,但仅在您实际发送了消息之后。即,如果您尚未称呼send()
或prisend()
,则可能不存在。您可以通过直接设置
messageID
属性来注入自己选择的消息ID,尽管如果根据 rfc 5322第3.6.4节。无需为此发明新的标题。
The mechanism in this issue is an internal identifier used by the receiving mail server, and is unrelated to the message ID. It's useful to know when looking at mail server logs, as usually every interaction with a client will be tagged with that ID, from initial connection through to delivery, which is not the case with the actual message ID.
You will find the actual message ID in
$mail->lastMessageID
, and I recommend retrieving it via$mail->getLastMessageID()
, but only after you have actually sent the message. i.e. if you have not yet calledsend()
orpreSend()
, it may not be there.You can inject a message ID of your own choosing by setting the
MessageID
property directly, though it will be ignored if it's not valid according to RFC 5322 section 3.6.4.There is no need to invent a new header for this.