[Phamm] Automatic creation of maildirs when using maildrop.
Jorge Armando Medina
jmedina a calcom.com.mx
Mar 2 Gen 2007 19:51:14 CET
Hi list.
After some time I finished the new revision of my howto,
Ok, this are the instruction for automatic creation of maildirs when we are
using maildrop as MDA.
First of all, we will use the virtual_mailbox_base = /home/vmail/domains
parameter as our filtering base.
Maildrop can use the /etc/maildroprc as the default and global filtering rules
file and per user files: .mailfilter we will use the last because it wont
affect our system when we upgrade maildrop.
As I said we will use /home/vmail/domains as our base, then we will create
there our .mailfilter file:
# touch /home/vmail/domains/.mailfilter
# chown vmail:vmail /home/vmail/domains/.mailfilter
# chmod 600 /home/vmail/domains/.mailfilter
NOTE: Don't forget to set those permisions.
Maildrop can use enviroment variables to make references to arguments and
directories:
Wi will use this global variables:
HOME=/home/vmail/domains
DEFAULT=domain.tld/username/
LOGNAME=username at domain.tld
Now, let's fill the .mailfilter file, the example is attached.
It is important to se the welcome message in phamm,
With this setup, whenever a new mail comes, maildrop will log something like
this to /home/vmail/maildrop.log
==== BEGIN maildrop processing for jmedina at tuxjm.net ===
Including /home/vmail/domains/tuxjm.net/jmedina/.mailfilter
Processing per user filters for: jmedina at tuxjm.net
Date: Tue Dec 26 02:43:47 2006
From: "Jorge Armando Medina" <jorgearma1982 at gmail.com>
Subj: Prueba usando maildrop como MDA.
File: tuxjm.net/jmedina/ (2391)
If we want to use per user filtering, we need to create a .mailfilter file in
the user mailbox directory, for example:
# cat /home/vmail/domains/tuxjm.net/jmedina/.mailfilter
log "Processing per user filters for: $LOGNAME"
if (/^X-Spam-Flag: YES/)
{
log "Moving Spamassassin tagged mails to the SPAM Folder"
log "into $LOGNAME Mailbox."
exception {
to $DEFAULT.SPAM/
}
}
You can comment the "log" parts, I configure them for better debuging.
For example you can see something in the maildrop.log file:
==== BEGIN maildrop processing for jmedina at tuxjm.net ===
Including /home/vmail/domains/tuxjm.net/jmedina/.mailfilter
Processing per user filters for: jmedina at tuxjm.net
Moving Spamassassin tagged mails to the SPAM Folder
into jmedina at tuxjm.net Mailbox.
Date: Sun Dec 24 02:42:19 2006
From: spammer at spammer.com
Subj: *****SPAM***** Do you viagra?
File: tuxjm.net/jmedina/.SPAM/
Well you can do a lot of practical things with maildrop, this is only one
example, for more info you can read this pages
http://gentoo-wiki.com/Maildrop_configuration
I hope this text is easy to understand, if not someone can rewrite it with a
bette english? :D
Best regards.
--
Jorge Armando Medina
Calcom de México S.A de C.V.
Telefono: 01 (664) 6238311
Email: jmedina at calcom.com.mx
-------------- next part --------------
# Ruta al /home/vmail/domains
VHOME="/home/vmail/domains"
# This extracts the username part from username at domain.tld
ACCOUNT=`echo "$LOGNAME" | cut -d@ -f1`
# This extracts the domain name from username at domain.tld
USERDOMAIN=`echo "$LOGNAME" | cut -d@ -f2`
# Path to the file where we will log the account creation.
VMAIL_LOGFILE="/home/vmail/maildrop-maildirmake.log"
# Path to maildirmake
MAILDIRMAKE=/usr/bin/maildirmake
# Let's check if /home/vmail/domain.tld/username exists
`test -d "$VHOME/$USERDOMAIN/$ACCOUNT"`
if( $RETURNCODE == 1 )
{
MESSAGE_DATE = `date`
# Log the creation date of this account in maildrop-maildirmake.log
`echo CREATION DATE: "$MESSAGE_DATE" >> $VMAIL_LOGFILE`
# Log the full path of the mailbox directory in maildrop-maildirmake.log
`echo EMAIL DIRECTORY: "$VHOME/$USERDOMAIN/$ACCOUNT" >> $VMAIL_LOGFILE`
# Log the username at domain.tld in maildrop-maildirmake.log
`echo USER EMAIL LOGIN: "$LOGNAME" >> $VMAIL_LOGFILE`
# Append a blanck line to maildrop-maildirmake.log
`echo " " >> $VMAIL_LOGFILE`
# Now check if the domain directory /home/vmail/dominio.tld exists.
`test -d "$VHOME/$USERDOMAIN"`
if( $RETURNCODE == 1 )
{
# Log the domain directory to maildrop-maildirmake.log
`echo CREATING DIRECTORY: "$VHOME/$USERDOMAIN" >> $VMAIL_LOGFILE`
# This creates the domain directory under /home/vmail/domains/
`mkdir -p "$VHOME/$USERDOMAIN"`
# Append a blanck line to maildrop-maildirmake.log
`echo " " >> $VMAIL_LOGFILE`
}
# Create the mailbox directory for the new account, this will be:
# /home/vmail/domains/domain.tld/username/
`$MAILDIRMAKE "$VHOME/$USERDOMAIN/$ACCOUNT"`
# Lets create the Sent directory for IMAP users
`$MAILDIRMAKE -f Sent "$VHOME/$USERDOMAIN/$ACCOUNT"`
# Suscribe the new Sent directory to the suscribed folders, only for courier-imap users.
`echo INBOX.Sent >> $VHOME/$USERDOMAIN/$ACCOUNT/courierimapsubscribed`
# Lets create the Thrash directory for IMAP users
`$MAILDIRMAKE -f Trash "$VHOME/$USERDOMAIN/$ACCOUNT"`
# Suscribe the new Trash directory to the suscribed folders, only for courier-imap users.
`echo INBOX.Trash >> $VHOME/$USERDOMAIN/$ACCOUNT/courierimapsubscribed`
# Create the curierimapuiddb directory under the user maildir
`touch $VHOME/$USERDOMAIN/$ACCOUNT/courierimapuiddb`
# Create the courierimapkeywords file under the user maildir
`mkdir -p "$VHOME/$USERDOMAIN/$ACCOUNT/courierimapkeywords"`
}
# GLOBAL VARIABLES
# HOME=/home/vmail/dominios
# LOGNAME=username at dominio.tld
# DEFAULT=dominio.tld/username/
# Log everything to this file
logfile "/home/vmail/maildrop.log"
# LOG BEGING OF FILTERING
log "==== BEGIN maildrop processing for $LOGNAME ==="
exception {
log "Including $HOME/$DEFAULT.mailfilter"
include "$HOME/$DEFAULT.mailfilter"
}
Maggiori informazioni sulla lista
Phamm