Yuval Hager - Drupal development and consulting

  • About
  • Blog
  • Services
  • Contact
Home

Simple outgoing mail server on Archlinux

Submitted by yhager on Wed, 12/09/2009 - 18:08
Photo by: 

curns@flickr

It is very common to need an outgoing mail capabilities. If you are using a VPS for your web site, or just you want outgoing mails on your home machine to work natively. Automatic messages from cron, UPS management, or even your blog about new comments are too important to lose.

I am using ArchLinux, but this guide is probably good for other distributions as well. I could not find a simple and concise guide for setting this up - this post is aimed to fill that gap.

First let’s install Postfix (why postfix? see below):

# pacman -S postfix

At this phase you might as well have the outgoing mail system already configured. However, you might just need a couple of variable settings before you are really ready to go.

The main configuration file /etc/postfix/main.cf contains the default with a lot of useful comments. We can read those later. In the mean time, we only need to edit the following (use your own domain instead of example.com):

myhostname = www.example.com
myorigin = example.com

Now edit the file /etc/postfix/aliases (Use your own local username instead of you) to say:

root: you

For this to take effect run

# newaliases

If you have already started postfix, you need to reload it now. It is probably safe just to use

# /etc/rc.d/postfix restart

One last thing to do is to make sure mail to you will end up in your mailbox (remember, this server is only meant for outgoing mail). Set up a file in your home directory (/home/you/.forward)

you@your.real.domain.com

That’s it!

Let’s test the new mail functionality. You can use console mail client if you have it installed, but since this is meant for PHP, I would like to test it works all the way:

$ php -a
Interactive shell

php > echo mail('yuval', 'Testing postfix basic', '(empty)');
1

Check your mail, you should have a mail from yourself :)

Why Postfix?

Postfix is a full blown MTA, that can serve as a mail server for your domain. It is not the first choice when you just need outgoing mail working. I was using ssmtp quite happily before that, but it is not being developed anymore. Another option is msmtp, but I got the impression it requires a “parent” SMTP server to direct mail onto.

Qmail is another option, but unfortunately it was deprecated in Archlinux. Postfix provides a very easy installation and configuration. It should also work when your system is offline (useful to get emalis from your UPS that you are out of electricity), since it manages a queue. Should you need a full blown mail system in the future, Postfix can serve that need to, without the need of migrating.

More info on Postfix basic configuration can be found at Postfix basic.

Tags:
  • linux
  • mail
  • postfix

2 reponses to "Simple outgoing mail server on Archlinux"

1. Thanks for sharing this guide

Submitted by hug (not verified) on Wed, 07/14/2010 - 09:16.

Thanks for sharing this guide of ArchLinux. I'll try it

  • reply

2. Thank you, thank you, thank

Submitted by Eronarn (not verified) on Tue, 01/25/2011 - 13:37.

Thank you, thank you, thank you! I can't believe it took so long to find this information - every other guide I looked at read like something out of the 1980s.

(I'm a Drupal developer myself, btw.)

  • reply

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

I love Smashing Magazine!
Fervens Drupal theme by Leow Kah Thong. Designed by Design Disease and brought to you by Smashing Magazine.