Archive for August 2010

Problems with From and BCC headers in PHP mail() Last updated:29 October 2010

Had a funny one this week. My wife discovered that nobody on her mailing list had received any emails since we swapped hosting packages back in May. Before the swap things were fine in a Windows server, now clearly not fine on Linux. On further investigation, I spotted that the From: and Bcc: headers weren’t being split out properly, and hence we were getting the Bcc was included in the From: field like this:

From:mail@mydomain.com Bcc: mail1@test.com, mail2@test.com etc etc

This was my original code:

$headers  = 'MIME-Version: 1.0' . "\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\n";
$headers .= "From: Sender <sender@mydomain.co.uk>"."\n ";
$headers .= "Bcc:".$bcc."\n";

mail($to, $subject, $message,$headers)

Same result replacing \n with \r\n. No joy even on Coding Forums, but after a lot of Googling I found the solution, which was to replace the newline characters with the PHP constant PHP_EOL:

$headers  = 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=utf-8' . PHP_EOL;
$headers .= "From: Sender <sender@mydomain.co.uk>".PHP_EOL;
$headers .= "Bcc:".$bcc.PHP_EOL;

mail($to, $subject, $message,$headers)

Glad to say this did the trick. PHP version 5.2.13 if anyone’s interested.

Well well… Last updated:29 October 2010

Entered a photography competition at the Ilkley Flower Show on Saturday – first time ever. Rather successful. The image below won first prize in the category “Winter Scene” – rather surprisingly as I thought although a good photo it wasn’t quite a scene as such.

Frozen leaf

And this one won third prize in “Something Red”.

Poppy bud

However, my daughter trumped me by winning first prize in “Something Red” and the Calder Cup for best photograph or painting in the show, with this one, taken with a Panasonic compact:

Hoverfly on a red flower

Everyone wants to know about jQuery UI Last updated:29 October 2010

Over the past month, the traffic on my site has more than doubled.

Graph showing web traffic increase

And it’s almost entirely due to this page which I wrote about using jQuery UI Slider for a vertical scrollbar. This one page now gets 30% of all the traffic. Even the traffic patterns are completely different, most hits to this page coming in the working week and from India and the US.

Amazing…