在发送电子邮件时,是否有某种方法可以从phpmailer获取消息ID?

发布于 2025-01-24 10:03:36 字数 629 浏览 0 评论 0 原文

使用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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谷夏 2025-01-31 10:03:36

此问题的机制与消息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 called send() or preSend(), 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文