1

Topic: [FAQ] How to use procmail to deliver mail (per-user setting)

This tutorial is used to explain how to use procmail to deliver mails in iRedMail. If they don't work for you, please post a new topic in iRedMail General Technical Support forum.
=====================

How to use procmail to deliver mail (per-user setting)
=======================

Since iRedMail supports per-user transport, it's possible and easy to set different transport or LDA (local deliver agent) to deliver mails for users.

Steps to use procmail instead of default sieve LDA:

  • Add below lines in postfix master.cf

procmail unix - n n - - pipe
  flags=DRhu user=vmail:vmail argv=/usr/bin/procmail -r -t SENDER=${sender} RECIPIENT=${recipient} DOMAIN=${nexthop} -m USER=${user} EXTENSION=${extension} /etc/procmailrc

Tip: iRedMail ships a sample procmailrc (iRedMail-x.y.z/samples/procmailrc), you can simplily copy it to /etc/procmailrc, but do NOT forget to change '$HOME' to correct directory. such as:

# MAILBOX="$HOME/$DOMAIN/$USER/"
MAILBOX="/var/vmail/vmail01/$DOMAIN/$USER/"
  • Create log file if necessary (NOTE: it's required if you use procmailrc shipped in iRedMail)

# touch /var/log/procmail.log
# chown vmail:vmail /var/log/procmail.log
# chmod 0700 /var/log/procmail.log
  • Set transport of this user in your MYSQL/LDAP backend.

    • In MySQL backend, change value of 'transport' column in vmail.mailbox table. set to 'procmail' (this is what we defined in postfix master.cf).

    • In OpenLDAP backend, change value of 'mtaTransport' attribute of this user.

  • Be CAREFUL, maildir generated by iRedMail is hashed, but seems procmail can't find them, so maybe you should change maildir related paths in SQL/LDAP of this user, so that it can receive mails. e.g.

    • In MySQL backend, you may want to change value of 'storagebasedirectory' and 'maildir' columns in vmail.mailbox table.

    • In LDAP backend, you may want to change value of 'storageBaseDirectory' and 'mailMessageStore' attributes.

    • It's a good idea to not mix procmail mailboxes and default LDA mailboxes, you may want to use /var/vmail/procmail01 as storageBaseDirectory instead of /var/vmail/vmail01 which used by default LDA. And don't forget to set correct file permission: