PHP mail() on Windows

Setting up an email server on Windows can be a real pain. Hardly worth the effort when all I want to do is using PHP’s mail() function.

I found a nice workaround when I updated my XAMPP installation: All you need is an SMTP server somewhere that you can use, because sendmail.exe will just forward the emails to it.

You still need to configure it though:

  1. Configure your SMTP in the sendmail.ini (located usually under C:\xampp\sendmail)
  2. In the php.ini, ensure you have the following set up
    [mail function]
    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

That’s it. Now you can quickly test it (below script more or less stolen from

$name = "Sender"; 
$recipient = ""; 
$email = ""; 
$mail_body = "The text for the mail...";
$subject = "Subject for reviever";
$header = "From: ". $name . " <" . $email . ">\r\n";

mail($recipient, $subject, $mail_body, $header);

If everything is set up correctly, you should notice that the execution of the script takes a moment. If it runs through fast, something did not work – or you have a really fast machine & connection.

Note: although I had some config errors the first time the error.log in the sendmail directory was not populated with any messages. I don’t know when this file will actually be used.

Create your own PHP extension (on Windows)

Have you ever thought about writing your own PHP extension? There are surely a few pro’s and con’s about creating PHP extensions to solve problems, rather than write PHP libraries. But this is not the question here. I was curious. So come on Internet, let’s see what you got for me…

Looks a bit outdated, but that’s not the problem here for me. As a matter of fact, I’m currently still using PHP 5.3.5 on my dev for a list of reasons. And I’m using Windows and I don’t complain (I know my colleagues think I’m weird). Luckily both tutorials cover the topic on how to create the extension on Windows for PHP 5.3.5. So much win! And the best: it really works!

Basically both tutorials provide you with everything you need. I had to get over two pitfalls though:

  1. php5ts.lib is not in the source code directory I just extracted, but in my WAMP stack already – in my case I located it in C:\xampp\php\dev
  2. error C2371: ‘socklen_t’ : redefinition; different basic types¬†– I really have no idea why this error came up during compilation. However I was able to “solve” *cough* the problem by commenting out lines 149 to 151 in the php.h:
    #ifndef HAVE_SOCKLEN_T
    typedef unsigned int socklen_t;

    Surely not the ideal solution, but as I just wanted to try it out I don’t mind at the moment.

Microformats – control what Google shows on the Search Results page

Yesterday I learned about “Microformats“. Microwhat? Sounds suspicious!

Well, at least that was my reaction. I’ve to admit that I don’t care much about SEO and Google and so on (I’m a PHP backend developer, Goddamit!), but this is really interesting topic one should at least have heard of. In short, it allows you to have influence on what is displayed on the Google results page. Worth its weight in Gold, I guess. Some of the ancients amongst us might remember the good old Metatags. It’s not the same, though.

So here’s a link that explains Microformats pretty well: