Tuesday September 07 , 2010
Text Size
   



Configuring Qmail

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PLEASE READ:

Updated 3/24/08: I have now removed outgoing auth on port 25. You can go to John Simpsons site and look up the options to turn this back on if you like. I would HIGHLY SUGGEST that you leave SMTP-AUTH on port 25 off and go on with the rest of the documentation. The next step is setting up SMTP with SSL. This is an alternate means to having your users sending mail. This way, You can turn on validrcptto, RBLs, jgreylist and the like without having your clients email programs time out on you. If they send mail via SSL, this will skip all these checks. Please let me know if you have any questions or problems by posting in the Forums on the left.

Updated 3/24/08: Added the qmail.sh to scripts.tgz file rather than have to download it manually.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Getting this part of qmail going is, well, going to be a little rough. We need to download the scripts for qmail-smtpd, qmail-send and qmail-pop3d. We will start with making all the needed directories and stuff like that so lets get to it!


# cd ~root
# mkdir qmail
# cd qmail
# fetch http://freebsdrocks.net/files/scripts.tgz
# tar zxvf scripts.tgz
# rm scripts.tgz

Double check the following in smtpd_run:

IP=1.2.3.4 Substitute your own IP address. Do not leave this set to 0 without a good reason.
PORT=25 Set the port number we will be listening on.
SSL=0 Do not run an SSL-only service.
FORCE_TLS=0 Refuse to accept mail from clients who have not done STARTTLS.
DENY_TLS=0 Do not refuse to process the STARTTLS command.
AUTH=0 We are turning off auth on port 25 and ONLY allow incoming mail.
REQUIRE_AUTH=0 Refuse to accept mail from clients who have not done AUTH.

Now lets make the supervise directory and get everything copied over:

PLEASE NOTE: Since there are a lot of commands here, I decided to make a little script for it.


# ./qmail.sh
# cd ~root
# rm -dfr qmail

Now lets setup some qmail aliases. Replace This e-mail address is being protected from spambots. You need JavaScript enabled to view it in the next three lines with the address you want the emails to go to:


# echo This e-mail address is being protected from spambots. You need JavaScript enabled to view it > /var/qmail/alias/.qmail-root
# echo This e-mail address is being protected from spambots. You need JavaScript enabled to view it > /var/qmail/alias/.qmail-postmaster
# echo This e-mail address is being protected from spambots. You need JavaScript enabled to view it > /var/qmail/alias/.qmail-mailer-daemon

The worst is over! Now we need to tell the pop3d run file the name of your server. Edit the following file and replace the section mail.domain.xxx with your mail server:


# vi /var/qmail/supervise/qmail-pop3d/run

Now we want to setup selective relaying:


# mkdir /etc/tcp/
# cd /etc/tcp
# fetch http://freebsdrocks.net/files/etc-tcp-makefile
# mv etc-tcp-makefile Makefile

Now we need to create the smtp file

At this point it should be ready to go. All you need to do is create the "smtp" file, containing the normal access control list. You may want to add the IP of the server you specified in the /var/qmail/supervise/qmail-smtpd/run file in the /etc/tcp/smtp file. Lets say the IP you used was 192.168.9.1. The line should look like this:


192.168.9.1:allow,RELAYCLIENT=""

This is what a typical smtp file should look like:


# vi /etc/tcp/smtp

Add the following to /etc/tcp/smtp:


192.168.9.:allow,RELAYCLIENT=""
:allow

Now run:


# gmake

and you should get an output saying:


tcprules smtp.cdb smtp.tmp < smtp
chmod 644 smtp.cdb smtp

Now on to the second part of qmail!