PHPMailer:替换默认的messageID [英] PHPMailer : replace the default messageID
问题描述
我使用PHPMailer发送电子邮件,evthg运行良好,但我会为每封电子邮件设置uniq MessageID。
PHPMailer版本:v5.2.16 >(从
而不是我的... :(
p>然后我尝试了更简单的方法:
$ mail-> MessageID =blablag@domain.com;
结果:KO相同)
文档指出我们可以设置一个MessageID,它应该是一个字符串,我不明白为什么它不起作用。
任何想法?
MessageID
应该是:
< sometext @ sometext>
如果 MessageID
没有这个确切的结构 - PHPMailer会忽略yo ur MessageId
并生成它自己的MessageId。
您可以将您的代码更改为:
$ mail-> MessageID =<。 MD5( HELLO(IDATE( U) - 1000000000).uniqid())。' - ; $ type.'-'.$id.'@domain.com>。
它应该可以工作。
I send emails using PHPMailer, evthg works well but I would to set a uniq MessageID for each email.
PHPMailer version : "v5.2.16"
(loaded with Composer from https://github.com/PHPMailer/PHPMailer.git)
I found the documentation here : http://phpmailer.github.io/PHPMailer/classes/PHPMailer.html#property_MessageID
so here is what I tried :
$mail = new PHPMailer;
...
$mail->MessageID = md5('HELLO'.(idate("U")-1000000000).uniqid()).'-'.$type.'-'.$id.'@domain.com';
Result : This is always the default MessageID generated by PHPMailer :
and not mine... :(
Then I tried sthg more simple :
$mail->MessageID = "blablag@domain.com";
Result : KO (the same)
The documentation indicates that we can set a MessageID, and it should be a string, I don't understand at all why it doesn't work...
Any idea ?
The structure of MessageID
should be:
<sometext@sometext>
If your MessageID
doesn't have this exact structure - PHPMailer will ignore your MessageId
and generate it's own MessageId.
You can change your code to:
$mail->MessageID = "<" . md5('HELLO'.(idate("U")-1000000000).uniqid()).'-'.$type.'-'.$id.'@domain.com>';
And it should work.
这篇关于PHPMailer:替换默认的messageID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!