Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exclamation mark is appears in email message body using phpmailer

Tags:

php

phpmailer

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...

like image 307
CodeWarrior Avatar asked Oct 11 '12 13:10

CodeWarrior


3 Answers

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

Try adding,

$mail->WordWrap = 50;
like image 169
Muthu Kumaran Avatar answered Nov 06 '22 02:11

Muthu Kumaran


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.

like image 38
karancan Avatar answered Nov 06 '22 03:11

karancan


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.

like image 38
phvish Avatar answered Nov 06 '22 03:11

phvish