I am currently having an issue with emails received that were sent from PHPMailer using plain/text emails. I am currently returning the email message from a database by fetching the row and saving into a variable $message. The message while in the database is formatted as such:
This is some email information. \r\n This is some more email information.
The email received is showing the message with the \r\n rather than returning a new line.
My PHPMailer Code looks similar to the following:
$subject = $row['subject'];
$message = $row['message'];
// PHP Mailer
$mail = new PHPMailer();
$mail->From = "[email protected]";
$mail->FromName = "MyWebsite.org";
$mail->AddAddress('[email protected]');
$mail->ContentType = 'text/plain';
$mail->IsHTML(false);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if(!$email->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
My question: How can I get \r\n to format properly using PHPMailer? Is this a PHPMailer setting or am I doing something wrong within my code?
It looks like you've saved \r\n
into your database as text - PHP will not parse that. You need actually save a new line into your 'message' in the database