我使用phpmailer在我的网站上发送电子邮件。我的代码运行良好,但有时在电子邮件正文包含感叹号在随机位置。我的代码如下:
$mail->SetFrom(FROM_EMAIL,FROM_NAME); //emailid of sender(admin)
$mail->Subject = 'Subject here.'; //subject of email
$mail->AddAddress(Address here); //emailid of user(recipient)
$content = 'some html code here';
$mail->MsgHTML($content); //this is body of email
$mail->Send();这可以很好地工作。但是找不到为什么有时会出现感叹号。先谢谢你...
发布于 2012-10-11 21:11:09
我认为这是因为电子邮件每行不能超过998个字符。
尝试添加,
$mail->WordWrap = 50;发布于 2013-02-08 06:56:06
我知道这很晚了,但是有一个替代的解决方案对我有效:
使用此行可以使用base64对整个消息进行编码:
$message = chunk_split(base64_encode($message));然后,将以下内容附加到您的标题中:
$headers .= "Content-Transfer-Encoding: base64\r\n\r\n";这将告诉邮件客户端您的消息是base64编码的。
发布于 2017-03-14 12:45:04
如果你使用的是PHPmailer,那么只需要一行代码就可以了:
$mail = new PHPMailer();
$mail->Encoding = 'base64';这将在内部执行内容传输编码: base64和chunk_split(base64_encode($message))。
https://stackoverflow.com/questions/12840212
复制相似问题