by shebang

Hi! I installed postfix quite some times and tried it on two different distros (slackware 9.1 & 10 && Gentoo 2004.0) and it worked flawlessly..

Ok. If you are only going to receive mail from Postfix, skip to the part about compiling & installing Postfix. Here we'll first install Cyrus-SASL 2.1.18 for SMTP Authentication when you are sending email. Get the Cyrus-SASL source from and then download: cyrus-sasl-2.1.18.tar.gz

NOTE: I'd suggest staying as root whenever you have to enter commands unless specified
After you are done, untar it:
# tar -xvzf cyrus-sasl-2.1.18.tar.gz
# cd cyrus-sasl-2.1.18
NOTE: If you are installing Cyrus-SASL 1.5 (just change the version numbers however, there are a few changes we'll make later if that's the condition
After cd'ing into the sasl directory:
# ./configure --enable-login --enable-plain --enable-anon
# make
# make install
# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
Ok. Here is what we are doing when we enable login and plain for SASL. For SMTP, there are some standards of how you authenticate yourself. Plain Authentication is the standard way but some ISPs require the non-standard way, which is the --enable-login part. Anon is in case you don't need SMTP authentication, it will let you login anonymously (this is very rare).
After you are done installing Cyrus-SASL, you are ready to install postfix.
COMPILING AND INSTALLING POSTFIX Get the postfix source from ( Choose your mirror ) At the time of this PET, the current version of postfix is 2.1.4 so if you have an older version of newer version substitute it with 2.1.4.
# tar -xvzf postfix-2.1.4.tar.gz
# cd postfix-2.1.4
Untar the source and cd into the co-ordinating directory.
Ok. Things change here a bit so read carefully. If you did NOT install SASL then follow the immediate instructions if not, skip to the part about SASL and Postfix.
# make
After you are done making, you have to make Sendmail "old" and then add the postfix user, postfix group, and postdrop group. I am using vi(m) as my editor, you can just use nano, pico, etc.
Do the following if you are sure you have sendmail installed:
# mv /usr/sbin/sendmail /usr/sbin/sendmail.OLD
# mv /usr/bin/mailq /usr/bin/mailq.OLD
# mv /usr/bin/newaliases /usr/bin/newaliases.OLD
After that:
# vi /etc/passwd
** Add this at the end of the file **
** Then Save the File **
# vi /etc/group
**Add this at the end of the file **
**Add this at the end of the file **
** Then Save the /etc/group File **
Then switch to the postfix src directory and then:
# cd /usr/local/src/postfix-2.1.4
# make install
Thanks to trickster for noticing a small error here instead of postfix:*:12345 i had postfix:12345
That's all you are going to need IF you didn't install Cyrus SASL. However, make install is user interface (which means it will ask you for some questions so not regular make install) Beware that there is no ./configure for postfix.
I usually go with the defaults for all the questions it will ask. So the root would be / and the config dir would be /etc/postfix, etc.
Now you will have to wait until I finish with SASL.
If you downloaded the Cyrus-SASL 2.1.18, then you will do this to compile postfix.
make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include/sasl" \
AUXLIBS="-L/usr/local/lib -lsasl2"
make install
The Make Install instructions are the same as above for NON-SASL users. It's usually good if you went with the default answer for all the questions it asks.
If you have SASL 1.5.5, will give you good info as to what to do. That document will also help you further your SASL installation. But here are the basic steps:

# make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include" \
AUXLIBS="-L/usr/local/lib -lsasl"
# make install
Ok. After you are done with Postfix, cd to /etc/postfix/
# cd /etc/postfix
# cp aliases /etc/aliases
# newaliases
# vi
NOTE: These options are mine own and your may differ so read the description for each option and DO NOT follow my options blindly.
There are some important changes you need to make in this file.
First set your hostname to (, that's what i have as my hostname).

NOTE: should be your `Hostname . Domainname` (without the spaces).
That's how mine looks
Now leave your mydomain commented. For your myorigin, it should look:
For your inet_interfaces, leave it to all
inet_interfaces = all
Unless, you have proxy interfaces, leave them commented. My mydestination looks like:
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
Yours might be different.
The rest of the options differ on your individual options. Now i'll just give you the SASL options. After the mail_spool_directory, I have:
smtp_sasl_auth_enable = yes
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtpd_sasl_local_domain = $myhostname
smptd_sasl_application_name = smtpd
These will remain the same for most people.
After you are done with the SASL & completely, save the file. In /etc/postfix:
** Create a newfile called sasl_passwd **
# vi sasl_passwd
in that file:
Code: username:passwd username:passwd username:passwd
NOTE: I cannot have my own SMTP because of my ISP, I have to relay it through them. The code if your ISP allows your own SMTP will be under the saslpasswd2 command section. GO there and check it out! For your own SMTP sort of thing you need to relay your mail through localhost. SMTP Relay: Localhost If you have a dyndns address (or any other service for dynamic IP), you need to keep updating your IP. You'd already know this but i'm just making sure. Then in your /etc/ , for your relayhost, make it equal your hostname so mine would look like:
Then you're all set!
The should be your ISPs SMTP address (or your hostname if you are on your SMTP). Those are the three lines that should exist in /etc/postfix/sasl_passwd After that file is created:
# postmap sasl_passwd
so there can be sasl_passwd.db file in /etc/postfix/.
Now you've just let Postfix see SASL and now SASL should see what authentication mechanisms to use. Now cd to your $PREFIX/lib/sasl2/ directory. My $PREFIX was /usr/local:
# cd /usr/local/lib/sasl2/
# vi smtpd.conf
We need to create a smtpd.conf file in that directory. Now, i have:
pwcheck_method: saslauthd
mech_list: plain login
This should work universally. So after you are done with your smtpd.conf file, you one more thing left to do.
  saslpasswd2 -c -u `postconf -h myhostname` username
That should ask you for the password and authentication.
NOTE: If you get a segmentation fault for this command, after the authentication, just ignore it. You WILL NOT have a /etc/sasldb2 file.
Now if you want to have your own SMTP and you got a segmentation fault:
# vi /etc/sasldb2 (or sasldb if you have 1.5)
user: test realm: (your hostname) mech: PLAIN
user: test realm: (your hostname) mech: LOGIN
user: test realm: (your hostname) mech: DIGEST-MD5
to /etc/sasldb2 (or sasldb if you are using SASL 1.5).
If you didn't get the segmentation fault, there should be a /etc/sasldb2 and if it isn't, then you haven't symlinked the /usr/local/lib/sasl2 with /usr/lib/sasl2.
Make sure the username is something different other than "username" for the saslpasswd2.
FINAL STEPS Then you have to:
Start Postfix!
# postfix start
If you have made changes to when postfix is running make sure you just reload postfix by:
# postfix reload
And to start postfix on boot up, add this to your /etc/rc.d/rc.local (for slackware)
postfix start
For Gentoo:
# rc-update add postfix default
If that doesn't work, try adding mail to the default runlevel. I've never rebooted gentoo after i installed it so if you have any questions, please come on to and join #linuxjunior or just PM me on the Forums.
Then if you are using Gentoo, ask your system logger to log the `mail` messages in /var/log/mail.log or whatever you like. Usually, it should be /var/log/messages.
If you are using other distros such as Slackware, etc. You can check for errors in /var/log/maillog.
# tail /var/log/maillog
That should tell you about your errors for postfix! Then get a mail client and then use your mailserver! I use mutt.
I have some credits that I need to give to. These two documents helped me a LOT and if you are at anytime confused in this here PET, i'd suggest going to those two sites.

  1. Documentation.

  2. gorn & chessforce for helping me set up my first postfix.
  3. Trickster for giving me the idea to make a PET
  4. Linux Junior for giving me an oppurtunity to learn Linux well and an oppurtunity to help others.