If you’re running a web application with user registration, you may need to have users or administrators receive email from the application. When you just need to send outgoing email and don’t need to receive, it’s easy to set up Postfix to do this for you. You can even set the “from” header so that replies will go to your own email account. This how-to was tested on Ubuntu 8.04 LTS server.

I’ve also written a post on sending mail using sSMTP which may be better suited for single user systems.

Install Postfix on your server:
sudo apt-get install postfix

During the installation of Postfix, you will be prompted to choose some settings for Postfix.

  1. For “type of mail configuration” select “Satellite system”.
  2. For “mail name” type the default domain name to use in outgoing emails.
  3. For “relay host”, set blank.

That’s all you need to send email with Postfix. Time to test it out:
sendmail EMAILADDRESS
FROM: FROMADDRESS
SUBJECT: hello world
this is a test email
.

The email will be sent to EMAILADDRESS with a reply address of FROMADDRESS. If this works, PHP’s mail() function should now also work.

For security, you should check that port 25 is still closed so nobody can connect to Postfix. This setup is working for me, but I’m no expert in Postfix or email and it’s possible you could have trouble with some spam filters rejecting mail sent this way without additional configuration.


Related Posts