Monday, July 26, 2010

Install Qmail and enable pop service for your site, setup in your training machine. Add an e-mail user and try sending and receiving emails through your site setup in training ?

The first step is to download the source code for qmail and any other add-ons. You'll need qmail, of course, and you should probably also get ucspi-tcp and daemontools:
Retrieve these files using your web browser, web client (e.g., wget), or FTP client.
If you made it this far, you have a working C compiler and copies of the tarballs. Next, copy or move the tarballs to the directory you want to do the work in. /usr/local/src is a good choice for qmail and ucspi-tcp. daemontools should be built under /package.
At this time you probably want to become root, if you're not already.
    su
    umask 022
    mkdir -p /usr/local/src
    mv netqmail-1.06.tar.gz ucspi-tcp-0.88.tar.gz /usr/local/src
    mkdir -p /package
    mv daemontools-0.76.tar.gz /package
    chmod 1755 /package
Now you can unpack the packages.
    cd /usr/local/src
    gunzip netqmail-1.06.tar.gz
    tar xpf netqmail-1.06.tar
    gunzip ucspi-tcp-0.88.tar.gz
    tar xpf ucspi-tcp-0.88.tar
    rm *.tar      # optional, unless space is very tight
    cd /package
    gunzip daemontools-0.76.tar.gz
    tar xpf daemontools-0.76.tar
    rm *.tar      # optional, again
There should now be directories called /usr/local/src/netqmail-1.06, /usr/local/src/ucspi-tcp-0.88, and /package/admin/daemontools-0.76.

Start qmail

/var/qmail/rc


The easiest way to create the necessary users and groups is to create a little script file to do it for you. In the source directory you'll find a file called INSTALL.ids. It contains the command lines for many platforms, so copying the file to another name and editing that is quick and easy.
    cd /usr/local/src/netqmail-1.06
    cp INSTALL.ids IDS
Then, using your favorite editor, remove all of the file except the lines you want. For example, here's what IDS would look like for FreeBSD after editing:
    pw groupadd nofiles
    pw useradd qmaild -g nofiles -d /var/qmail -s /nonexistent
    pw useradd alias -g nofiles -d /var/qmail/alias -s /nonexistent
    pw useradd qmaill -g nofiles -d /var/qmail -s /nonexistent
    pw useradd qmailp -g nofiles -d /var/qmail -s /nonexistent
    pw groupadd qmail
    pw useradd qmailq -g qmail -d /var/qmail -s /nonexistent
    pw useradd qmailr -g qmail -d /var/qmail -s /nonexistent
    pw useradd qmails -g qmail -d /var/qmail -s /nonexistent
Then to run it, either use chmod to make it executable or run it with sh:
First method:
    chmod 700 IDS
    ./IDS
Second method:
    /bin/sh IDS
When the script finishes, all of your users and groups will be created and you can go on to the next section.
But what do you do if your system isn't listed in INSTALL.ids? You'll have to create them manually. Start by using your favorite editor and editing /etc/group. You need to add the following two lines to the end of the file:
    qmail:*:2107:
    nofiles:*:2108:

Qmail With POP

Qmail includes a POP server, qmail-pop3d, but it's not configured and installed as part of the qmail installation process. qmail-pop3d is the POP server included with qmail. It's a fine POP server, and many qmail sites use it. It's modular, and supports multiple authentication schemes via alternative authentication modules.

Installation of qmail-pop3d

1. Completely install and test qmail. If you want all users to have POPable mailboxes, make sure defaultdelivery is set to ./Maildir/. If you installed the /var/qmail/rc script from the Installation section, this is configured in control/defaultdelivery. If not, it's probably in /var/qmail/rc on the qmail-start command line.
2. Download a checkpassword program from http://www.qmail.org/top.html#checkpassword. The standard checkpassword, http://cr.yp.to/checkpwd.html, is a good choice if you don't need anything fancy.
3. Compile and install checkpassword according to the directions. Make sure you install it as /bin/checkpassword.

4. mkdir /var/qmail/supervise/qmail-pop3d
5. Create a /var/qmail/supervise/qmail-pop3d/run script containing:
#!/bin/sh
exec /usr/local/bin/softlimit -m 2000000 \
    /usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup \
        FQDN /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir 2>&1
where FQDN is the fully qualified domain name of the POP server you're setting up, e.g., pop.example.net.

6. mkdir /var/qmail/supervise/qmail-pop3d/log
7. Create a /var/qmail/supervise/qmail-pop3d/log/run script containing:
#!/bin/sh
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t \
    /var/log/qmail/pop3d
8. Set up the log directory and permissions on the run scripts, and link the service into /service:
    chmod +t /var/qmail/supervise/qmail-pop3d   # if daemontools < 0.75
    mkdir /var/log/qmail/pop3d
    chown qmaill /var/log/qmail/pop3d
    chmod 755 /var/qmail/supervise/qmail-pop3d/run
    chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
    ln -s /var/qmail/supervise/qmail-pop3d /service
9. Add the following to qmailctl's "start" section:
    if svok /service/qmail-pop3d ; then
      svc -u /service/qmail-pop3d /service/qmail-pop3d/log
    else
      echo qmail-pop3d supervise not running
    fi
10. Add the following to qmailctl's "stop" section:
    echo "  qmail-pop3d"
    svc -d /service/qmail-pop3d /service/qmail-pop3d/log
11. Add the following to qmailctl's "stat" section:
    svstat /service/qmail-pop3d
    svstat /service/qmail-pop3d/log
12. Add the following to qmailctl's "pause" section:
    echo "Pausing qmail-pop3d"
    svc -p /service/qmail-pop3d
13. Add the following to qmailctl's "cont" section:
    echo "Continuing qmail-pop3d"
    svc -c /service/qmail-pop3d
14. Add the following to qmailctl's "restart" section:
    echo "* Restarting qmail-pop3d."
    svc -t /service/qmail-pop3d /service/qmail-pop3d/log

No comments:

Post a Comment