Tagged as Linux
Written on 2008-03-05 04:54:12
For those who don't know, Wordpress is the blogging software I run on my server. Whenever a comment is left though if it passes through my spam filters it goes to a moderation queue to be approved by me. This is practical for two reasons: 1) In spite of my spam filter (Akismet) being competent, it's not perfect and stuff still slips through. 2) I have low enough traffic that I can keep up with the moderation queue pretty closely.
However, until today there was a drawback to this. Wordpress is supposed to send out e-mails for various reasons but it never worked and the reason is that the program it needed to send mail (called sendmail, cleverly enough) I didn't install by default with Ubuntu 6.06 Server (now upgraded to 8.04).
Now, sendmail is not a mail client like Outlook, Thunderbird, or iMail. It's a MTA (Mail Transfer Agent) and frankly I have no desire to run an MTA on my server. That's overkill and it's just one more thing that can get hacked. So today, I did two things. 1) Set up ssmtp as an alternative that pushes everything to my gmail account. 2) Installed a plugin so I get notifications whenever a comment is in the moderation queue and the user gets an e-mail letting them know too.
Here's how I did it:
For the debian-based kids, try running:
sudo apt-get install ssmtp
After that completes, you're going to want to:
sudo nano /etc/ssmtp/ssmtp.conf
There are six values you'll want to change in here and they should look like the following:
mailhub=smtp.gmail.com:587
AuthUser=youremail@gmail.com
AuthPass=pass
UseSTARTTLS=YES
hostname=machinehostname
FromLineOverride=YES
From there you'll want to hit Ctrl-O Ctrl-X to save and exit. After that you'll need to tell your php configuration to use ssmtp instead of the default (sendmail). So type:
sudo nano /etc/php5/apache2/php.ini
and hit Ctrl-W, then type sendmail and hit enter to search for sendmail in the document. You should find something called sendmail_path, modify it to look like:sendmail_path = /usr/sbin/ssmtp -t -i -au username -ap password -am LOGIN
Restart your Apache server to take advantage of the changes by typing:
sudo /etc/init.d/apache2 restart
Finally, download this to your server and unzip it into /wordpress_root/wp-content/plugins and activate it in the plugins menu. That's it!
References:
SSMTP Gmail Guide
SSMTP Guide for PHP on Debian/Ubuntu
Wordpress Plugin