This article was originally published on August 26, 2008.
I would not have figured out all this if it hadn’t been for someone on the #linode channel with the patience to walk me through the steps.
At any rate, when I moved abettergeek from Dreamhost to Linode, mail quit working in the forums. PHP has a built in
mail() function, but it requires some server config to work – apparently, Dreamhost took care of that, while Linode’s default Linux install doesn’t have sendmail installed by default.
This makes sense – Linode basically allows you to select from a number of Linux distros, and they drop a very barebones image onto your VPS. It’s up to you to install the things you need. This is better than, say, installing everything by default and leaving a bunch of ports and vulnerabilities open from the start.
sendmail, however, is a bit pickier than Apache when it comes to making it work properly. These steps are using Ubuntu 8.04 LTS, but they’ll be similar for any Linux distro.
First, you’ll want to actually install sendmail:
apt-get install sendmail
That part was easy…however, the default Ubuntu config did not have my hostname information configured properly. You’ll need to update your
hosts file and your
sudo nano /etc/hosts
If you have a line that looks like
127.0.0.1 ubuntu, remove it. The top two lines of the file should look like this:
127.0.0.1 localhost 22.214.171.124 abettergeek.com
Then, you need to update your
sudo nano /etc/hostname
This needs just one line for your domain:
Restart your server for the changes to take effect, and you should be able to now send mail using the
mail() function in PHP.