Keep it simple: Linux-based mail server

Daily Newsletters

Sign up to ZDNet UK's daily newsletter.

Compile and install Postfix
Unpack the source tarball as follows: $ tar --xzf postfix-2.0.6.tar.gz Create a postfix user account, with the primary group named postfix, using your account creation tool of choice. This account should have no shell or home directory -- the resulting entry in /etc/passwd should look like this: postfix:*:12345:12345:postfix:/no/where:/no/shell Create a postdrop group with no users. The entry in /etc/group should look like this (perhaps with a different group id): postdrop:*:54321 Add an entry in /etc/alias for the postfix user: postfix: root The following makecommand will patch the make files for MySQL support. Also, change the include and lib path to point to the directories containing mysql.h and libmysqlclient. So: $ cd /usr/src/postfix-2.0.6
$ make --f Makefile.init makefiles
> 'CCARGS=-DNO_PCRE -DHAS_MYSQL --I/usr/local/mysql/include/mysql'\
> 'AUXLIBS=-L/usr/local/mysql/lib/mysql --lmysqlclient --lz --lm' Remove the debugging symbols from the source code (optional) with this command: $ strip bin/* libexec/*
Then compile using: $ make
Finally, install (as root) using these commands: $ su
# make install
The install script prompts you for many options. You might want to specify a location in your user home directory for the readme files -- otherwise, the defaults are generally fine. Barring any compilation errors, you should now have a working copy of Postfix on your system, with a directory of configuration files in /etc/postfix. Configuring Postfix
Postfix has a ton of configuration options. After a fresh install, most of them are set to reasonable values. The readme files, sample configuration files, and man pages describe how to work with most of them. While Postfix should run with no changes, there are some settings you may need to change if you're getting error messages, along with a couple of considerations for reducing spam. Using Table A, you may want to change some values in /etc/postfix/main.cf (the main configuration file for options). Table A
main.cf parameter Description Set this value
alias_maps Lists where to find local users alias_maps = hash:/etc/alias
mynetworks Determines what IP address range to accept mail from. Defaults to accepting mail from any computer on the same subnet. If this computer is not behind a firewall, set it to specific IP addresses to always accept mail from mynetworks = 127.0.0.0/8 12.228.122.48/32
relayhost Designates another SMTP server to relay all mail not delivered locally. By default, this is set to nothing, meaning this server attempts to connect directly to the receiving MTA. If you have a local DNS server running, this is fine -- otherwise you might want to point this to the mail server for your ISP.
smtpd_recipient_restrictions Determines what to check before relaying the mail. You can add black hole lists here, check for forged Hotmail/Yahoo mail, and many other things.

Here's a basic list that blocks unauthorized relaying and connections that do not speak proper SMTP:smtpd_recipient_restrictions = reject_unauth_pipelining,  reject_unknown_sender_domain,  reject_unknown_recipient_domain,  permit_mynetworks,  reject_unauth_destination

Here are the main.cf configuration file options.
Next, I need to set up aliases for default system accounts. For now, I'll route the important mail accounts to a local user account, which will need to be read directly by a mail client. To do this, edit the /etc/aliases file and add the following entries: postfix:    root
postmaster: root
abuse:      root
root:       user Replace user with your user account name. To generate the actual alias database, type the following as root: # postalias
Next, check for errors in the Postfix installation, and if you get no error messages, start Postfix: # postfix check
# postfix start
Postfix sends log messages to the mail facility of syslogd by default. Look for messages from Postfix that include /var/log/maillog, /var/log/mail/warnings, or their equivalents. The tail command can be helpful for this:$ tail --f /var/log/maillog
Automatic startup
Finally, set Postfix to run automatically at startup. The procedure to do this varies widely by system, and the package does not provide a script. If your distribution uses System V for starting and stopping services, the accompanying sidebar provides a sample script you can use. Save this script as /etc/rc.d/init.d/postfix. Once this script is saved, you can use the chkconfig program to set the run levels for postfix, and make the script executable using: # chkconfig -- add postfix
# chmod 744 /etc/rc.d/init.d/postfix What's next?
Postfix should now be up and running, accepting mail for local users and aliases in the /etc/alias file, and relaying mail out. In the next article, I will set up an IMAP server so that other users can get to e-mail stored on the server and store virtual user accounts in a MySQL database. For a weekly round-up of the enterprise IT news, sign up for the Enterprise newsletter. Tell us what you think in the Enterprise Mailroom.

Post your comment

In order to post a comment you need to be registered and logged in.

You can also log in with Facebook. Log in or create your ZDNet UK account below

  • Login

Will not be displayed with your comment

By signing up for this service, you indicate that you agree to our Terms and Conditions and have read and understood our Privacy Policy. Questions about membership? Find the answers in the Community FAQ

Get ZDNet UK's daily newsletter

Enter your email address to sign up

ZDNet UK Live

bordero

ike fuelband is great for every healthminded person ! to work out! theres this website called textme4free.com that you can use to text anywhere in...

7 hours ago by bordero on Nike's FuelBand wristband gamifies exercise
BrownieBoy

> I'm told it's somewhat annoying when people have their Macs stolen > and Apple stores treat the thief as the owner, but there you go. Ouch,...

9 hours ago by BrownieBoy on AMD Ultrathins to challenge Intel Ultrabooks
Moley

@kevinmchapman. OK, I acknowledge that 'most' was a gratuitous throwaway comment as an afterthought and too presumptuous. As to proof, as you...

13 hours ago by Moley on A tale of two distros: Ubuntu and Linux Mint
Jack Schofield

@BrownieBoy > Works really well for thieves.... >> Nice attempt to deflect the argument by tossing in a point that's totally >> irrelevant, even...

15 hours ago by Jack Schofield on AMD Ultrathins to challenge Intel Ultrabooks
raskolnikof

fantastic that the so called piracy bills have been withdrawn. however, these anti-democracy supporters are still in the shadows so lets be alert...

15 hours ago by raskolnikof on SOPA, Protect IP support wavers in face of online protest
Tony Douglas

Please God no; teach them anything you like - thinking rationally, the uses and misuses of data, what data is and what it's not - but leave the...

18 hours ago by Tony Douglas via Facebook on Kids are the future. Teach ’em to code.
BrownieBoy

@Jack, > Works really well for thieves.... Nice attempt to deflect the argument by tossing in a point that's totally irrelevant, even it were...

1 day ago by BrownieBoy on AMD Ultrathins to challenge Intel Ultrabooks
bootlegger

Make that 13 people now - I got refused today at Manchester airport. I thought I was up to date on this legislation - I knew of the EU ruling from...

1 day ago by bootlegger on UK airport body scans will not be opt out
tinycg

Don't forget to check out apps like GoodReader or SlideShark either, they're indispensible for people on the go in presentation situations. Best...

2 days ago by tinycg on Four top iPad apps for people on the move
TerryRK

Well it seems there is something a number of us agree on. Why is the Ubuntu Unity launcher so ugly? I thought perhaps it was something to do with...

2 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
Freebies202

Duplicate comments are not made intentionally. Its very good to know that now you are keeping check on this problem because sometimes a commenter...

2 days ago by Freebies202 on Microsoft fixes blog comments, speeds up blogs with open source
kevinmchapman

"the very significant number of users" and "many (most) of us" - you have no evidence for these statements. It is a fact that most users are saying...

2 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
Marg Menzies Harrison

Another grammar faux pas is the improper use of "you". When sitting down down in a restaurant, for example, I get cringe when the waitress...

3 days ago by Marg Menzies Harrison via Facebook on 10 flagrant grammar mistakes that make you look stupid
zdnetukuser

And NOW, folks, for Canonical's next trick... Kubuntu is late. Here's a pencil. Draw your own conclusions. cf.:...

3 days ago by zdnetukuser on Linux Minterface
Moley

@kevinmchapman. The discussion here reflects the very significant number of users who really do like the traditional menu system and who wish to...

3 days ago by Moley on A tale of two distros: Ubuntu and Linux Mint
kevinmchapman

Er, no... It is an efficient means of finding the application/file/setting you need in one place. The icons are a simply a fallback for when you...

3 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
TerryRK

Isn't the provision of a text based search an admission by the developers that the mass of icons approach does not work? I don't need to use a...

3 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
kevinmchapman

"Unity and GNOME 3 both abandon the old text-based cascading menus in favour of a graphical icon-driven system." Point truly missed. Both use a...

3 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
TerryRK

whs001 - Thank you, I'm glad you liked the article. I absolutely agree with you on your first point. I should perhaps have made it clearer that...

3 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
Dennis Nilsson

If we allow corporate interest to dictate the way our government circumvents due process against foreign entities then we should accept the same...

3 days ago by Dennis Nilsson via Facebook on ACTA stumbles in Germany

Inside ZDNet UK