3

I have an interface to send e-mails through SMTP (I use the plug-in Postman SMTP).

I collect messages in the DB that I sent to someone depending on the results of an SQL request.

In the DB, I stored the messages using the char 
 for line breaks.

Here is the code (I replace e-mail addresses with xxx, but obviously I use my client's e-mail address in the real piece) :

$subject = $res->subject;
$message = utf8_encode( $msg );

$to = $res->url ;
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: XXX <[email protected]>' . "\r\n" .
  'Reply-To: [email protected]' . "\r\n";         

$sent = wp_mail($to, $subject , $message , $headers);

Everything works (I receive the right e-mail with proper encoding), however everything is sent on a single line (when there should be a line break each time there is a &#13; in the database message). Oddly, there are no in the e-mail, they are just deleted from the message.

I also tried to add the following lines (on separate tests, obviously) :

$message = str_replace('&#13;', "\r\n", $message);
$message = str_replace('&#13;', '<br />', $message);

But I get the same results.

Could you please help me sort this out ?

1 Answer 1

1

Modify the line that reads $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; to $headers .= 'Content-Type: text/html; charset=ISO-8859-1"; and then use <br /> for the line breaks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.