Testing mail() On Apache

Updated March 2017: fixed the code to display from gist snippet.

Here is a simple way of testing if your mail() function is working. I’ve used this script to test if the mail servers are properly working. From time to time I’m asked to migrate websites to new DNS’s. When I’m setting up the MX Records, I need to test to make sure the server sends / receives e-mails.

To test outgoing mail using PHP’s mail() function, simply create testmail.php and use this:

Very straight forward, set $to variable to your own e-mail. Edit the $subject and $body if needed. The if conditional will e-mail you if the mail() function exists! Otherwise, you get fail. 🙁

Read More


Whether or not I actually commit to blogging is an eternity of suffering on my end. I’ve purchased countless domains, started new projects and had ideas flop here and there. I guess that’s the nature of a web geek. I’m very surprised the domain CodeSleepShred.com hasn’t been snatched up… Intrigued, I decided to start this blog. I am trying to disassociate from my professional life in this blog for now. Perhaps humoring myself is the key to actually forcing myself to blog.

My goals is to provide an alternative lifestyle blog to the Pacific Northwest. If I were to draw a venn diagram of the PNW, it would encompass: extreme sports, cars, and technology. There is no doubt that this blog will eventually spill into my professional life. But for now, I will be focusing on building content.

O Hai!

Read More