I'm getting exclamation points in random spots in the result of this PHP email function. I read that it's because my lines are too long or I have to encode the email in Base64 but I do not know how to do that.
This is what I have:
$to = "[email protected]";
$subject = "Pulling Hair Out";
$from = "[email protected]";
$headers = "From:" . $from;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 64bit\r\n";
mail($to,$subject,$message,$headers);
How do I fix this so there's no random ! in the result? Thanks!
The exclamation mark indicates that this is a new contact that has been entered, but hasn't been verified as a legitimate contact that you want to keep in the database.
It's called the negation unary operator. It flips the Boolean value (coercing to Boolean if need be) of a value. For example... ! 0; // True !
Let's start with the definition of the exclamation point (!) from about.com: A punctuation mark (!) used after a sentence that expresses a strong emotion.
Markup Declaration Open: "<!", when followed by a letter or "--" or "[", signals one of several SGML markup declarations. The only purpose it serves in HTML is to introduce comments.
Try to use this piece of code:
$to = "[email protected]";
$subject = "Pulling Hair Out";
$from = "[email protected]";
$headers = "From:" . $from;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 64bit\r\n";
$finalMessage = wordwrap( $message, 75, "\n" );
mail($to,$subject,$finalMessage,$headers);
The problem is that one line should not be longer than 998 characters. (see also https://stackoverflow.com/a/12840338/2136148)
As stated here: Exclamation Point in HTML Email
The issue is that your string is too long. Feed an HTML string longer than 78 characters to the mail function, and you will end up with a ! (bang) in your string.
This is due to line length limits in RFC2822 https://www.rfc-editor.org/rfc/rfc2822#section-2.1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With