How to remove “on behalf of” in PHP mail for Outlook 2007 and 2010

December 14th, 2011 by Alex Leave a reply »

Anyone noticed that stupid “; on behalf of;” bug in subject when you received email with Outlook 2007 and 2010?

Well, the fix is pretty simple. While we were setting the From: <> header, now we need to set the Sender header too. So it looks like:

$header.="Sender: $from\r\n";
$header.="From: $from\r\n";
$header.="MIME-Version: 1.0\r\n";
$header.="Content-Type: text/html; charset=utf-8\r\n";
$header.="Content-Transfer-Encoding: 8bit\r\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $text, $header);

And that’s it. It took me a while googling for the issue to find it, but hopefully it saves your day!

Comments are closed.