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…
I think it’s because the email messages can’t have more than 998 characters on one line.
$mail->WordWrap = 50;
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.
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.
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));