exclamation mark is appears in email message body using phpmailer

三世轮回 提交于 2019-12-21 04:38:20

问题


I m using phpmailer for sending emails in my website. My code works fine but sometimes in email message body contains exclamation mark at random places. My code is as follows:

$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();

This works fine. But can't find why exclamation comes sometimes. Thanks in advance...


回答1:


I think it's because the email messages can't have more than 998 characters on one line.

Try adding,

$mail->WordWrap = 50;



回答2:


I know this is late but there is an alternate solution that worked for me:

Use this line to encode your entire message using base64:

$message = chunk_split(base64_encode($message));

Then, append this your header:

$headers .= "Content-Transfer-Encoding: base64\r\n\r\n";

That will tell the mail client that your message is base64 encoded.




回答3:


if you are using PHPmailer then only one line of code should help:

$mail = new PHPMailer();
$mail->Encoding = 'base64';

this will do Content-Transfer-Encoding: base64 and chunk_split(base64_encode($message)) internally.




回答4:


I had this problem also, after long searching I have found that you should wordwrap your HTML

$emailContent = '<p>some large html</p>';
$mail->msgHTML(wordwrap($emailContent, 50));


来源:https://stackoverflow.com/questions/12840212/exclamation-mark-is-appears-in-email-message-body-using-phpmailer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!