kzr
kzr

Reputation: 11

Pear Mail won't send if From header has scandinavian characters

Imagine the following:

$from = "Testäöå <[email protected]>";
....
$headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject,
    'MIME-Version' => "1.0",
    'Content-type' => "text/html; charset=iso-8859-1");

If the $from variable is just "Test <[email protected]>", script works fine.

Upvotes: 1

Views: 249

Answers (1)

cweiske
cweiske

Reputation: 31108

Since you're specifying the headers directly, you need to escape them manually. Only ASCII characters are allowed in headers, so you need to escape them.

You can do that i.e. with

'=?UTF-8?B?'.base64_encode($from).'?='

Alternatively, you can use the Multibyte string functions as described in the comments of http://pear.php.net/manual/en/package.mail.mail.send.php :

$encodedFrom = mb_encode_mimeheader($from, 'UTF-8', 'Q');

Upvotes: 1

Related Questions