Qmail Howto | Go Back

Now, we can run make and install qmail.

# echo “-lssl -lcrypto” > ssl.lib
# make
# make setup check

Note: If you get an error while running “make” that says: “Oops. Your system’s FD_SET() has a hidden limit of 1024 descriptors. This means that the qmail daemons could crash if you set the run-time concurrency higher than 509. So I’m going to insist that the concurrency limit in conf-spawn be at most 509. Right now it’s 1000.” - edit the file conf-spawn in your qmail directory and change the concurrency limit from 1000 to 509. Save and run make again.

If for some reason you are trying to compile qmail-1.03 instead of netqmail-1.05, you might encounter compilation problems with the latest versions of glibc (especially on Redhat Linux 9). In this case, use this patch and try recompiling qmail again. To apply the patch, cd to your qmail directory and type patch -p1 < qmail-1.03.errno.patch

Qmail and all of its subdirectories are installed in /var/qmail. Now we move to the configuration step.

8) Qmail post-install configuration
Before moving any further, it is best to create a link to qmail sendmail wrapper. The reason why we want this, is because many programs use sendmail to send email messages. By default, sendmail is installed in /usr/sbin/sendmail or /usr/lib/sendmail. We are going to symlink the wrapper:

# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

Now we need to create necessary control files in /var/qmail/control. The examples below assume that your domain is “yourserver.com”. Of course, you have replace the occurence of yourserver.com with your qualified MX host.

# cd /var/qmail/control
# echo yourserver.com > defaultdomain
# echo localhost > locals
# echo yourserver.com > me
# echo yourserver.com > plusdomain
# echo localhost > rcpthosts
# echo yourserver.com >> rcpthosts
# echo checkvpw > checkpassword
# echo 1 > mfcheck
# echo 20 > tarpitcount
# echo 5 > tarpitdelay

The next step is to create various messages such as bounce and double bounce messages.

# echo @nowhere.edu > badmailfrom
# echo @nowhere.edu > badrcptto
# echo mailer-daemon > bouncefrom
# echo yourserver.com > bouncehost
# echo 50000 > bouncemaxbytes
# echo text > bouncemessage
# echo failure notice > bouncesubject
# cp bouncehost doublebouncehost
# cp bouncemessage doublebouncemessage
# cp bouncesubject doublebouncesubject

I will explain below in section 18.1 what “badmailfrom” and “badrcptto” are for and how to use them to fight against nasty spammers.

Now we need to edit two files - bouncemessage and doublebouncemessage. Therefore, launch your favorite editor and replace “text” with your bounce message. These files will contain the text that’s going to be displayed when a message bounces or double bounces. The example below uses vi to edit the files.

# vi bouncemessage
# vi doublebouncemessage

OK, the control files are all completed. Qmail configuration is now complete. The last thing that we need to do is set up a qmail startup script.

# vi /var/qmail/rc

Copy-paste the following into the file:

#!/bin/sh
PATH=”/var/qmail/bin:/usr/local/bin”
export PATH
cd /
qmail-start ./Maildir | setuidgid qmaill
multilog t n50 s1000000
/var/qmail/logs/qmail &

The first two lines of the script specify the path to executable files (so that we don’t have to write the complete path to qmail-start, setuidgid and multilog). The third line starts qmail, specifying Mailbox as the default directory for a mail user and sets “qmaill” as the user account under which multilog will be executed. The next line executes multilog, which is the logger we will be using for qmail. Here, we specify the number of maximum log files allowed in log directory (50) and the maximum size of a log file (1 MB). When a log file reaches 1 MB in size, the log will automatically rotate by renaming “current” log and creating a new empty log. When the number of log files reaches 50, it will automatically remove the oldest log prior to creating a new one. The last line represents the log directory.

Of course, we should not forget about making the startup script executable and creating qmail log directories:

# chmod 755 /var/qmail/rc
# mkdir /var/qmail/logs
# mkdir /var/qmail/logs/qmail
# chown -R qmaill:qmail /var/qmail/logs

9.1) Installing Ucspi-UNIX

# cd /usr/local/src
# tar zxf ucspi-unix-0.36.tar.gz
# cd ucspi-unix-0.36
# make
# ./installer

Note: If ucspi-unix fails during compilation with an error in env.c (sysdeps.h not found) you need to get bglibs and install it. After untarring the source, cd into the directory and run “make” followed by “make install”. Try recompiling ucspi-unix again. If compilation of ucspi-unix finishes without an error, type “./installer” to install binaries and manuals into /usr/local/bin and /usr/local/man, respectively. In some cases the installer gives an error “installer error: Could not change directory to ‘/usr/local/man’”. If you got this error just type “mkdir /usr/local/man” and then “./installer” again.

9.2) Installing Ucspi-TCP
The process is similar to qmail installation:

# cd /usr/local/src
# tar zxf ucspi-tcp-0.88.tar.gz
# cd ucspi-tcp-0.88
# wget http://www.qmail.org/ucspi-rss.diff
# patch -p1 < ucspi-rss.diff
patching file rblsmtpd.c
# make
# make setup check

Note: If ucspi-tcp fails during compilation with an error “collect2: ld returned 1 exit status”, you need to get two patches (patch 1, patch 2) and apply them to ucspi-tcp. Put these patches into /usr/local/src/ucspi-tcp-0.88 directory and type “patch -p1 < ucspi-tcp-0.88.errno.patch" and “patch -p1 < ucspi-tcp-0.88.nobase.patch". As usual, you’ll have to rerun “make” and “make setup check” to compile and install ucspi-tcp.

Now let’s configure tcpserver. Create a script called tcprulesedit in /usr/local/bin and copy-paste the following:

#!/bin/sh
vi /etc/tcp.smtp
/usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp

This script will take care of creating and editing relay rules in qmail. You can substitute “vi” with your favorite editor, if you want to.

As usual, make the script executable:

# chmod 755 /usr/local/bin/tcprulesedit
# tcprulesedit

The second line above runs the tcprulesedit script we’ve just created. Copy-paste the following lines into the editor:

127.:allow,RELAYCLIENT=”",RBLSMTPD=”",QMAILQUEUE=”/var/qmail/bin/qmail-queue”
:allow,QMAILQUEUE=”/var/qmail/bin/qmail-scanner-queue.pl”

Note: If you are not planning to install qmail-scanner, you should remove the QMAILQUEUE definitions above. Of course, don’t forget to get rid of all “,” (commas) at the end of the lines as well.

For security purposes, we are only allowing localhost (127.) to relay messages. Since messages coming from localhost will most probably not contain spam or viruses, we are specifying qmail-queue as the default executable for incoming mail. This will also decrease the server load when processing mail between local mail users. The second line of the script just tells tcpserver to process all other mail using qmail-scanner (to fight against spammers and viruses), the installation of which I will be covering later in this guide.

10) Moving on with Daemontools
Daemontools installation differs from other installations, because you don’t have to “configure” or “make” the package. A directory is created in your root structure, and all working files are placed there. Follow the instructions below to properly install Daemontools on your system.

# mkdir -p /package
# chmod 1755 /package
# cd /package
# mv /usr/local/src/daemontools-0.76.tar.gz /package
# tar zxf daemontools-0.76.tar.gz
# mv daemontools-0.76.tar.gz /usr/local/src
# cd admin/daemontools-0.76
# package/install

Note: If daemontools fails during compilation with an error “collect2: ld returned 1 exit status”, you need to get a patch and apply it on daemontools. Put the patch into /package/admin/daemontools-0.76 and type “patch -p1 < daemontools-0.76.errno.patch". After the patch is applied successfully, cd into /package/admin/daemontools-0.76 and type “package/install”. Daemontools should now be installed and fully operational.

That’s it, Daemontools package is installed.

Pages: 1 2 3 4 5 6

Posted by MegaZ on 12/20/2002.

69 Responses to “Qmail Howto”

Pages: [5] 4 3 2 1 » Show All

  1. 69
    Nelson Says:

    Nice tutorial. This is only the patch that I haven’t encountered a problem.

    I hope you can add a patch such as validrcptto. This is nice patch. However, I’m getting a hunk failed when I’m trying to patch it after patching all the patch on your tutorial. Probably, some code doesn’t conform to validrcptto patch. I’m not a C programmer so I’m getting a hard time fixing the problem. Please inform me via my email ntserafica@yahoo.com if you have the patch.

    This could be a great gift this coming christmas :)

  2. 68
    Martin F Says:

    So what if I want a more minimalistic solution. Basically I have a mail server that only needs to serve one site, and primarily outgoing mail. So no fancy stuff needed like multiple users and auto-responders.

    I would like to have a suite of admin tools, for instance, being able to manually send an email that’s been stuck in the queue and watching the remote mail server response, ideally have a php script parse this information.

    Hours on Google have really only given me scripts for the end-user, none for really managing the admin part of qmail.

  3. 67
    Carlos Says:

    > - Qmail Patches from http://megaz.arbuz.com

    Where is the patches, i find but…

  4. 66
    hugl3 Says:

    Nice tutorial. If anyone needs help, you can contact my via email on my website.
    I could do it for free.

  5. 65
    Bill Says:

    This was helpful. Thank you.

  6. 64
    Jorge Reteguin Says:

    Hi Nasim:

    Have you tried to use CourierIMAP 4.3.1 (with AuthLib)?
    I would appreciate your comments about it.

    Thanks.

  7. 63
    Yuriy Says:

    Hi Nazim,

    Sometimes I have an error when sending email(addresses which I used before or new):

    An error occurred while sending mail.The mail server responded: sorry, that domain isn’t in my list of allowed rcpthosts(#5.7.1). Please check the message recipients and try again.

    I thought that it something to do with timing out authentication so I have removed 900 from /etc/relay-ctrl/expiry(step 12->Installing Relay-CTRL; pagehttp://megaz.arbuz.com/2002/12/20/qmail-howto/4) but I’m still getting this error.
    I’ll appreciate if you could advice on what could be wrong, please.

    Thanks a lot in advance,
    yuriy

  8. 62
    Yuriy Says:

    Hi Nazim,

    Problem with setting second virtual domain was sorted out. It turned out that one needs to restart qmail server after adding another virtual domain.
    Also I have sorted an issue with 550 error page(I have wrote about it in one of my previous posts).
    With virtual domain .qmail-default file should exist for each user. So solution was pretty simple: copy original .qmail-default to .qmail-USERNAME in /home/email/yourdomain/ folder. Also my /etc/tcp.smtp looks like this:

    127.:allow,RELAYCLIENT=”",RBLSMTPD=”",QMAILQUEUE=”/var/qmail/bin/qmail-queue”
    :allow,QMAILQUEUE=”/var/qmail/bin/qmail-scanner-queue.pl”,VERIFY=”"

  9. 61
    Yuriy Says:

    Hi Nazim.
    I can telnet to my server and do all steps you have listed alright. It’s just when I’m trying to set additional virtual domain it stops receiving emails(one can still send emails though) even to the first virtual domain. When I remove the second virtual domain it will start to receive emails but only after couple hours.I reckon that it’s Qmail-Scanner coursing this problem. I probably leave this issue to sort later on(I’m planning to install another test server but will keep in mind using more than one domain then).
    I have couple more issues which require immediate attention and I was trying to sort them out but no luck so far.
    1. I need to set our email server to give a 550 error for an invalid address. I have used Andrew Richards’ qmail-verify patch(http://free.acrconsulting.co.uk/email/qmail-verify.html). I can see qmail-verify daemon is running on our server but it’s not rejecting non-existing users(so it’s accepting anything with our domain). The problem could be that /home/email/[virtual_domain]/.qmail-default telling that anything coming with this domain is valid.
    But because I’m using virtual domain .qmail-default pipes to /usr/local/bin/vdeliver.So vdeliver is deciding who is right users on our server. Andrew suggested to remove /home/email/[virtual_domain]/.qmail-default but when I did it email server stopped to receive emials. Do you know what parameters I need to pass to /usr/local/bin/vdeliver in /home/email/[virtual_domain]/.qmail-default so qmail-verify can properly filter email users?
    2. Due to the increase in the number of ISP’s blocking port 25 for third party mailservers I need to set on mail server additional port to answer SMTP request. I was looking on google and found the following link http://www.skorpionweb.org/archives/2005/09/running_qmail_s.php.
    So I followed the logic in this article and set separate tcpserver which listens to different port:
    1) Created /var/qmail/rc2 :
    #!/bin/sh
    PATH=”/var/qmail/bin:/usr/local/bin”
    export PATH
    cd /
    qmail-start ./Maildir | setuidgid qmaill \
    multilog t n50 s1000000 \
    /var/qmail/logs/qmail2 &

    2) Created /usr/local/bin/runmail2:
    exec softlimit -m 10000000 \
    envdir /etc/relay-ctrl relay-ctrl-chdir \
    tcpserver -v -H -R -l $HOSTNAME -x /etc/tcp.smtp.cdb -c200 -u5002 -g5000 0 587 qmail-smtpd 2>&1 &

    3) Created /var/qmail/logs/qmail2 and chown it to qmaill:nofiles.

    Now I can start separate tcpserver with port 587 and everything looks healthy with but when I change port 25 to 587 and try to send mail I have got an error “…The server may be unavailable or refusing connection…”
    I wonder whether I need to set another instance of qmail-smtpd(may be qmail-smtpd2, just guessing here).

    Thanks a lot again for your time and effort to keep this site going & helping folks like myself :-)
    Kind regards, yuriy

Pages: [5] 4 3 2 1 » Show All

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Powered by WP Hashcash