# MailScanner Installation Guide - ZMailer

## How mailscanner works with ZMailer

As ZMailer has a clear distinction between the accepting of a message (either via SMTP with smtpserver or locally via the sendmail command), the routing and the delivery of the message, MailScanner sits between the accepting and the routing of the message.

That is, in the graph that shows ZMailer's processes interaction, you would see a new MailScanner process processing messages from the input spool and leaving them in the router spool.

Unlike Sendmail, Exim and Postfix implementations of ZMailer, you don't need two instances of ZMailer to run MailScanner, but you slightly modify one part of a standard ZMailer setup. In fact, the equivalent of the "incoming sendmail" part of a standard MailScanner installation is done by a slightly differently configured `smtpserver`; and the equivalent of the "outgoing sendmail" part, is done by a standard `router` and `scheduler`.

There are two ways of installing ZMailer and MailScanner, that is, you grab the sources and compile ZMailer, and get the MailScanner tarball and configure everything manually, or, in a GNU/Linux environment with RPM support you install everything via RPM.

Here you'll find instructions to handle both kinds of setup: using RPM or Manual

## RPM Installation

- First, install Xosé Vázquez's standard ZMailer RPM 2.99.55-5 or newer.
- Then install MailScanner RPM version 4.23-5 or newer as explained here.
- Now, stop ZMailer and disable its startup script (it will be later started by MailScanner's startup script):

`service zmailer stop
chkconfig zmailer off`

- Now, you create the new postoffice-incoming with this script:

`./modify-zmailer.sh
`
(you have to be root to run it). The script is very simple and has "-v" options on everything it runs so you see what's happening.

- To modify ZMailer's configuration, download this patch and apply it. Supposing you saved it in /tmp:

`cd /
patch -p0 < /tmp/ZMailer-2.99.55-5.rpm-MailScanner.patch`

- To modify MailScanner's startup configuration, edit the file `/etc/sysconfig/MailScanner`, comment out the following line:

> and uncomment the following one:

> `#MTA=zmailer`

- Now edit MailScanner's configuration file (/etc/MailScanner/MailScanner.conf), modify the line that looks like:

`MTA=sendmail`

> so it says:

> `MTA=zmailer`

> and the lines:

> `Incoming Queue Dir = /var/spool/mqueue.in
> Outgoing Queue Dir = /var/spool/mqueue`

> so they look like:

> `Incoming Queue Dir = /var/spool/postoffice-incoming/router
> Outgoing Queue Dir = /var/spool/postoffice/router`

- Now you're ready to go, simply enable MailScanner to start whenever the machine boots and start it (this starts MailScanner as well as ZMailer:

`chkconfig --add MailScanner
chkconfig MailScanner on
service MailScanner start
`

## Manual Installation

### How to Set Up ZMailer for MailScanner Use

1. Install ZMailer (version 2.99.55 or newer) and get it all working.
2. Stop ZMailer using a command
   `zmailer stop`
3. Create a new postoffice for smtpserver to leave messages in.
   (suppose your current postoffice is at /var/spool/postoffice)
   `mkdir /var/spool/postoffice-incoming
   chmod 2755 /var/spool/postoffice-incoming
   mkdir /var/spool/postoffice-incoming/public
   chmod 3777 /var/spool/postoffice-incoming/public
   mkdir /var/spool/postoffice-incoming/router
   chmod 3777 /var/spool/postoffice-incoming/router
   mkdir /var/spool/postoffice-incoming/freezer
   chmod 3777 /var/spool/postoffice-incoming/freezer
   chown -R root:mail /var/spool/postoffice-incoming
   rm -f /var/spool/postoffice/.pid.smtpserver
   ln -sf /var/spool/postoffice-incoming/.pid.smtpserver /var/spool/postoffice
   `
4. You must edit the zmailer.conf file and add a line like this:
   `POSTOFFICEIN=/var/spool/postoffice-incoming`
   (e.g under the line that starts with `POSTOFFICE=`), then look for the `SMTPOPTIONS` variable in there (that specifies the line command options to call smtpserver) and add
   `-P ${POSTOFFICEIN}`
   among those options.
   This will make smtpserver to leave messages in `/var/spool/postoffice-incoming/router` instead of `/var/spool/postoffice/router`.

### How to Set up MailScanner for Use with ZMailer

In your MailScanner.conf file (probably in /etc/MailScanner or /opt/MailScanner/etc), there are 3 settings you need to change. They are all really near the top of the file. The settings are

        Incoming Queue Dir = /var/spool/postoffice-incoming/router
        Outgoing Queue Dir = /var/spool/postoffice/router
        MTA = zmailer

However, you should check where is zmailer's sendmail emulation program and configure the following variables accordingly:

        Sendmail = /usr/local/zmailer/bin/sendmail

        Sendmail2 = /usr/local/zmailer/bin/sendmail

### Starting It All Running

1. Start ZMailer
   `zmailer`
2. Start MailScanner
   `check_MailScanner`

### Startup scripts

Unlike the standard RPM Insallation, I like to have independent startup scripts for starting ZMailer and MailScanner. The standard ZMailer RPM package by Xosé Vázquez has a startup script for ZMailer. I left a copy here for you to grab.

I also modified a version of MailScanner's startup script so it only starts MailScanner independently from the MTA. It is here and it should run with any MTA, provided you convince the MTA to start its two instances apropiately, as we described for ZMailer here.

Julian Field