Mail Server Setup Manual

Table of Contents:
About this Document
Mail Archiving
Target Mail Servers
Setting up POP3/IMAP Server
Setting up SMTP Server
Install Milter Program

About this Document

This document describes the mail server settings required for archiving mail messages in MailDepot. Please refer to the documentation provided with each of mail server software for individual installation/setup procedure.

Mail Archiving

MailDepot does mail archiving by regularly importing mail messages from the specified POP3/IMAP servers. Therefore, it is necessary to copy all mail messages from the SMTP servers to the private MailDepot account.

Further, since multiple POP3/IMAP servers and accounts can be specified, POP3/IMAP servers need not be located in one place. They may be distributed in several places.

Target Mail Servers

The mail servers which are dealt with in this document are :

SMTP Server

POP3/IMAP Server

Setting up POP3/IMAP Server

This section will explain about the set up of the POP3/IMAP server. Unless otherwise specified, the name of the private POP3/IMAP account used by MailDepot will be "maildepot", and the OS account will be used for POP/IMAP server account management. If you use authentication servers such as LDAP, account settings will be required for your authentication servers.

dovecot

  1. Create Private Account

    Create an account for POP3/IMAP server to receive mail messages (not necessary if already created).

    # adduser maildepot
    
  2. Setup dovecot

    Edit dovecot.conf as follows to enable POP3 or/and IMAP protocols. Please add other protocols if required.

    # Protocols to be used : imap imaps pop3 pop3s
    protocols = pop3 imap
    

    Dovecot support mbox format and Maildir format for user's mailbox. To use Maildir format, set mail_location parameter as follows.

    # Location for users' mailboxes.
    mail_location = maildir:~/Maildir
    
    Start or restart dovecot server after changing parameters.

qpopper

  1. Create Private Account

    Create an account for POP3 server to receive mail messages (not necessary if already created).

    # adduser maildepot
    
  2. Setup qpopper

    If required, edit qpopper.conf and set it up. If qpopper is started via (x)inetd, edit inetd.conf or xinetd.conf to accept a POP3 connection.

Courier-IMAP

  1. Create Private Account

    Create an account for POP3/IMAP server to receive mail messages (not necessary if already created).

    # adduser maildepot
    
  2. Setup Courier-IMAP

    Enable authdaemon and pop3d (and/or imapd for IMAP) daemon.

    /usr/lib/courier-imap/etc/pop3d:
      POP3DSTART=YES
    
    /usr/lib/courier-imap/etc/imapd:
      IMAPDSTART=YES
    
  3. Create Mail box

    Create a mail box on user's home directory.

    $ cd ~maildepot
    $ /usr/lib/courier-imap/bin/maildirmake Maildir
    

    SMTP server must support Maildir format for local delivery, since Courier-IMAP supports only Maildir format.

Cyrus IMAP

  1. Setup Cyrus IMAP

    Edit cyrus.conf to enabe POP3 or/and IMAP protocols, and start/restart Cyrus IMAP server.

    SERVICES {
    ...
        pop3            cmd="pop3d -U 30" listen="pop3" prefork=0 maxchild=50
        imap            cmd="imapd -U 30" listen="imap" prefork=0 maxchild=50
    
  2. Create Private Account

    Create a user account by using the saslpasswd2 command and cyradm command.

    $ saslpasswd2 -c cyrus
    $ saslpasswd2 -c maildepot
    $ cyradm --user cyrus localhost
    passwd: ********
    > cm user.maildepot
    > quit
    

    (Please change the name of the system administrator "cyrus" according to your environment)

Setting up SMTP server

Setup for SMTP server is given below. Please refer to the documentation provided with each of mail server software for individual installation/setup procedure.

Postfix

Use always_bcc function

Postfix deliver blind carbon copy of all mail messages to specified mail address by setting always_bcc parameter. You can also use sender_bcc_maps or recipient_bcc_maps parameter to copy partial mail messages specified by sender/recipient address.

Append the following line in main.cf to forward all copied mail messages to a specific POP3 account.

always_bcc = maildepot@localhost

If POP3 server supports only the Maildir format (Courier-IMAP etc.), set home_mailbox as follows to store copied mail messages using Maildir format.

home_mailbox = Maildir/

Start/restart postfix after changing parameters.

# systemctl restart postfix

Postfix add Delivered-To: header for copied mail messages to record recipient address.

Use milter function

Postfix 2.3 or later support Sendmail version 8 Milter protocol. With this function, you can copy all mail messages processed by postfix. To copy all mail messages with this function, you have to install milter program that handle Milter protocol. See Install Milter Program to install milter Program.

To use milter function in postfix, set smtpd_milters parameter in main.cf as follows.

smtpd_milters = inet:localhost:9999

You must set this parameter to socket address of milter process configured by milter program.

After changing parameters, start/restart postfix server.

# systemctl restart postfix

Sendmail

Sendmail does not provide any functions to copy mail messages, but Sendmail 8.12 or later supports Milter Protocol. With this Milter function, you can copy all mail messages processed by sendmail. To copy all mail messages with this function, you have to install milter program that handle Milter protocol. See Install Milter Program to install milter Program.

To use milter function in sendmail, you have to configure sendmail by updating sendmail.cf file. The following procedure is required to update sendmail.cf on RedHat Linux. To update sendmail.cf, you have to install sendmail-cf packages in advance.

  1. Backup sendmail.cf
  2. # cd /etc/mail
    # cp sendmail.cf sendmail.cf.bak
    # cp sendmail.mc sendmail.mc.bak
    
  3. Add milter rule to /etc/mail/sendmail.mc as follows
  4. define(`_FFR_MILTER', `true')dnl
    INPUT_MAIL_FILTER(`Milter', `S=inet:9999@localhost, T=C:10m;S:1s;R:1s;E:5m')dnl
    

    You have to chanage underline part to socket address of milter process configured by milter program.

  5. Generate sendmail.cf from sendmail.mc
  6. # cd /etc/mail
    # m4 < sendmail.mc > sendmail.cf
    
  7. Restart sendmail
  8. # systemctl restart sendmail
    

Install Milter Program

If your mail server (MTA) supports Milter protocol, milter program can filter and copy all mail messages by communicating your mail server with Milter protocols. Many milter program is provided with different functions.

MailDepot provides its own milter program named md_milter for some mail servers that support Milter protocol. With md_milter program, you can copy all mail messages with Envelope Header that is added by md_milter program automatically. This additional header is essential to use Bcc Search feature and Personal Search feature in MailDepot.

About md_milter

md_milter is a milter program developed for MailDepot.

md_milter copies all mail messages into Maildir folder with envelope header. MailDepot imports copied mail messages with Maildir supported POP3 server like dovecot. md_milter can invoke optional mail filter program for copied mail, and can send copied mail to optional forward address.

md_milter add optional Envelope header as follows.

X-Envelope-From: Sender Address
X-Envelope-To: Recipient Address

With this envelope header, MailDepot can provide Bcc Search and Personal Search feature.

Install md_milter

md_milter is located in MailDepot Installation CD.

On RedHat Linux, install milter program with rpm command as follows.

RHEL7 / CentOS 7
# yum install -y sendmail-milter
# rpm -ihv md_milter/rpms/rhel7-x86_64/maildepot3-milter-1.05-3.*.rpm
RHEL8 / AlmaLinux 8 / Rocky Linux 8
# dnf install -y sendmail-milter
# rpm -ihv md_milter/rpms/rhel8-x86_64/maildepot3-milter-1.05-3.*.rpm
RHEL9
# dnf config-manager --set-enabled codeready-builder-for-rhel-9-x86_64-rhui-rpms
# dnf install -y sendmail-milter
# rpm -ihv md_milter/rpms/rhel9-x86_64/maildepot3-milter-1.05-3.*.rpm
AlmaLinux 9 / Rocky Linux 9
# dnf config-manager --set-enabled crb
# dnf install -y sendmail-milter
# rpm -ihv md_milter/rpms/rhel9-x86_64/maildepot3-milter-1.05-3.*.rpm

If you use other operation system than Redhat Linux, you have to compile and install as follows.

# mkdir md_milter
# tar xvzf .../md_milter/src/md_milter-1.05.tar.gz
# make DEST=/opt/maildepot3 clean
# make DEST=/opt/maildepot3 all
# make DEST=/opt/maildepot3 install
# install -c -m 755 misc/maildepot-milter.rc /etc/rc.d/init.d/maildepot2-milter
# install -d /opt/maildepot3/var/lock/subsys

You need to install compile tools (like GNU C Compiler and Gnu make, etc) and development libraries (like glibc and sendmail, etc). For more detail, see documentation file included in md_milter-1.0.tar.gz.

Setup md_milter

Create configuration file in following location.

/opt/maildepot3/etc/md_milter.conf

Set following parameters in above configuration file.

# socket address for milter
port=inet:9999

# directory of maildir folder
maildir=Maildir

# run as user
user=maildepot

# discard to deliver
#discard=1

With above settings, md_milter copyies all mail messages into Maildir folder for maildepot user. MailDepot imports copied mail messages via Maildir supported POP3/IMAP server like dovecot.

For more detail aboud setting parameters, please refer documents located in following directory.

/opt/maildepot3/share/doc/md_milter/

Start md_milter

After settings, start md_milter as follows.

# systemctl start maildepot3-milter