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 ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ 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:
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
# tar -xvzf cyrus-sasl-2.1.18.tar.gz
# cd cyrus-sasl-2.1.18
After cd'ing into the sasl directory:
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).
# ./configure --enable-login --enable-plain --enable-anon
# make install
# ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
After you are done installing Cyrus-SASL, you are ready to install postfix.
COMPILING AND INSTALLING POSTFIX Get the postfix source from http://www.postfix.org http://www.postfix.org/download.html ( 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.
Untar the source and cd into the co-ordinating directory.
# tar -xvzf postfix-2.1.4.tar.gz
# cd postfix-2.1.4
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.
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
Then switch to the postfix src directory and then:
# 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 **
Thanks to trickster for noticing a small error here instead of postfix:*:12345 i had postfix:12345
# cd /usr/local/src/postfix-2.1.4
# make install
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.
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.
make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include/sasl" \
If you have SASL 1.5.5, http://www.postfix.org/SASL_README.html 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:
Ok. After you are done with Postfix, cd to /etc/postfix/
# make makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/local/include" \
# make install
NOTE: These options are mine own and your may differ so read the description for each option and DO NOT follow my options blindly.
# cd /etc/postfix
# cp aliases /etc/aliases
# vi main.cf
There are some important changes you need to make in this file.
First set your hostname to hostname.mine.nu (grumble.mine.nu, that's what i have as my hostname).
NOTE: hostname.mine.nu 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
Unless, you have proxy interfaces, leave them commented. My mydestination looks like:
inet_interfaces = all
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:
These will remain the same for most people.
smtp_sasl_auth_enable = yes
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_local_domain = $myhostname
smptd_sasl_application_name = smtpd
After you are done with the SASL & main.cf completely, save the file. In /etc/postfix:
in that file:
** Create a newfile called sasl_passwd **
# vi sasl_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/main.cf , for your relayhost, make it equal your hostname so mine would look like:
Then you're all set!
The smtp-sbcglobal.yahoo.com 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:
so there can be sasl_passwd.db file in /etc/postfix/.
# postmap sasl_passwd
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:
We need to create a smtpd.conf file in that directory. Now, i have:
# cd /usr/local/lib/sasl2/
# vi smtpd.conf
This should work universally. So after you are done with your smtpd.conf file, you one more thing left to do.
mech_list: plain login
That should ask you for the password and authentication.
saslpasswd2 -c -u `postconf -h myhostname` username
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:
CREATE THAT FILE AND ADD THE CONTENTS BELOW TO IT
# vi /etc/sasldb2 (or sasldb if you have 1.5)
to /etc/sasldb2 (or sasldb if you are using SASL 1.5).
user: test realm: grumble.mine.nu (your hostname) mech: PLAIN
user: test realm: grumble.mine.nu (your hostname) mech: LOGIN
user: test realm: grumble.mine.nu (your hostname) mech: DIGEST-MD5
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:
If you have made changes to main.cf when postfix is running make sure you just reload postfix by:
And to start postfix on boot up, add this to your /etc/rc.d/rc.local (for slackware)
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 irc.freenode.net and join #linuxjunior or just PM me on the Forums.
# rc-update add postfix default
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.
That should tell you about your errors for postfix! Then get a mail client and then use your mailserver! I use mutt. http://www.mutt.org
# tail /var/log/maillog
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.
- http://www.postfix.org Documentation.
- gorn & chessforce for helping me set up my first postfix.
- Trickster for giving me the idea to make a PET
- Linux Junior for giving me an oppurtunity to learn Linux well and an oppurtunity to help others.