Almost two years have passed since my last blog post, so I thought something nice and techy would be good to get started with again.
I'm new to managing my own server, I've always left it to WHM and cPanel to look after everything. After signing up with Linode and getting a basic web server up and running (Apache, PHP, MySQL) on an Ubuntu, I hit a problem. I wasn't able to send email from PHP. I needed to install a mail server.
In the past I've heard all sorts of horror storied regarding mail servers and therefore avoided managing anything myself – I've always left it to Google Apps (even though your typical WHM / cPanel sever can handle it – it wasn't worth the hassle). Knowing email servers hard a bit reputation for newbies to learn, I had no idea where to start.
The Linode Library has numerous guides for getting a full incoming and outgoing mail server setup – but they seemed incredibly technical and covered absolutely everything. All I wanted to do was send from PHP. No incoming mail, no sophisticated logging, no SMTP logins from email clients.
- Connect via SSH to your server
- Install Postfix by running
sudo apt-get install postfix
- During the installation process, you will be prompted to set some configuration options. Choose the following values:
1) Type of Mail Configuration: Select “satellite system”.
2) Mail name: If you're only hosting one site, enter the domain name for that site. If you're hosting multiple sites, use something generic such as the FQDN for your server. It's not too important what you set it as here, you can easily override it by setting a “From:” header when sending an email.
3) Relay host: You should leave this field blank.
- That's it! You should have a basic outgoing mail server installed.
You can test that everything has installed correctly by sending a mail from the command line by entering the following commands (don't forget to replace the email addresses):
sendmail email@example.com FROM: firstname.lastname@example.org SUBJECT: Postfix mail server test This is a test message to test my installation of Postfix.
You should now have an email on it's way to your inbox. If it arrives, you should be able to send email from PHP using the