Web DevelopmentWierd Exclamation characters in the html email

Wierd Exclamation characters in the html email

In case you are trying to send an html email via the mail function in PHP and you are getting weird formatting and exclamation characters, then you need to insert line breaks (“\n”) into the message of your email

Check out the php documentation @ http://php.net/manual/en/function.mail.php
It says: Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.

So if you are getting badly formatted email, one of the reasons is because of this.

Just before you send your email, you can do this

$email_message = "blah blah blah ..... a long email message.....";
$email_message =  wordwrap($email_message, 70, "\n");
mail($to, $subject, $email_message, $headers);  //send email

Categories: Web Development

Comments

  1. pungi

    April 26, 2011 8:37 am

    thanks this helped. I just added line below to ensure this. $HtmlReport =~ s/(.{0,200}S+)s+/$1n/g;

Post a comment

Your email address will not be published. Required fields are marked *