Question

Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg

Here is the PHP code that I use:

$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
        $date = date('Y-m-d');
        $subject = "Tack för Ert köp! / Thank you for your order!";
        $headerFields = array(
    'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
        "Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
        "From: {$to}",
    "MIME-Version: 1.0",
    "Content-Type: text/html;charset=utf-8"
        );
 mail($to, $subject, $message,  implode("\r\n", $headerFields));

So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?

Was it helpful?

Solution

You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.

Try passing null as the second argument instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top