Sending email via Gmail using PHP & Postfix

So I’ve started trying to teach myself PHP and MySQL.  I’ve built a CentOS 5.5 server and have installed a LAMP environment to play around with.  While stepping through the exercises and playing with the mail() function in PHP, I realized that my test messages weren’t being delivered.  A friend pointed out that I didn’t install the Sendmail package, which typically installs w/ CentOS, but he suggested I install Postfix instead as it’s easier to manage and not quite as temperamental as Sendmail.  After installing Postfix, the PHP script would work, but it took about 10-15 minutes to send the message and even then, it would get routed to my Gmail SPAM folder.  After a considerable amount of digging I finally fixed it.

I’ve attached a link below to the original article I referenced to fix my problem (originally written by Jeremy Bouse), but have also snipped/edited the specific steps I used, just in case the original article disappears in the future.

(snipped and modified)

The first step is to create the file containing your authentication credentials. For this I used /etc/postfix/sasl_passwd to which I added this line:

You’ll want to be sure this file is protected so I recommend root:root ownership and 0600 permissions be set on it. You’ll then want to run the following to create the hash mapped version as root.

postmap hash:/etc/postfix/sasl_passwd

Below is a copy of the lines I added to the bottom of my file:


myhostname = localhost.localdomain
mydestination = localhost.localdomain
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_sasl_security_options =
smtp_tls_security_level = may
relayhost =

After making these changes to the config file, I reloaded Postfix so it would pick up the changes, reran my PHP script containing the mail() function and it worked like a champ.

Moving the \users directory in Windows 7

In previous versions of Windows, I was always disappointed about the inability to relocate the \users directory.  I typically partition my drives so that Windows is installed on its own partition and then use a separate partition for installing applications and documents.  Over time, however, the \users directory would eventually become bloated as a result of varying application installations and since I was installing the OS on a brand new 64Gb SDD this time, I wanted to keep the footprint as small as possible (don’t get me started on the gluttonous \Winsxs folder).

After spending some time searching for a way to move the \users folder, I tripped across this posting which detailed a way to do it without having to hack the registry to pieces.  It sounded fairly straight forward and since I was doing a fresh installation of Windows 7, I wasn’t concerned about the outcome.

Needless to say, this method has worked just fine for me.  Other than having to remember that the c:\users folder actually resides on the d:\ drive (even when it appears in Windows Explorer to live in c:\), I haven’t had any problems.

(tap tap) Is this thing on?

My very first blog post.  How exciting.

Actually, I’m about as leery of this as I was my first haircut, but I’m going to give it a try anyway.  My main purpose for starting this blog is to force me to learn a lot of the technology that I feel I’ve let pass me by: Networks, PHP, HTML, CSS, Apache, MySQL, Linux, Java, Virtualization, Samba….the list goes on.

I’m a fairly technical guy, but I need to dig a little deeper into the details and I think this will be a good way to get started.  My intent is to provide a little chronology to where I started and where I end up going, as well as document all of the hiccups I fully expect to encounter along the way.  Knowing the way I tear into things, there is no doubt that I am going to totally crater a server.  I’m hoping that by taking notes of my mistakes, I can not only refer to them later, but possibly prevent somebody else from making the same ones.  I’m also hoping to get some valuable advice from those who’ve been doing this much longer than I.

And since it’s my blog and I can do whatever I want to with it, I’ll probably share some random thoughts or funny stories along the way.

Onward through the spam….


I’m pink, therefore I’m SPAM.