PDA

View Full Version : Maildrop Postfixadmin create mail directories


tecstream
18th July 2008, 22:28
Running Centos 5.2 Postfix Mailscanner, Mailwatch, Maildrop, Mysql, Courier-Imap, Postfixadmin.

Can not auto create mail directories. As I understand it now upon first mail a directory is to be created /home/vmail/$domain/$user but this does not occur any help would be appreciated.

This is my maildrop test and log instance

maildrop -V 9 -d testcreate@example.net

maildrop: authlib: groupid=5000
maildrop: authlib: userid=5000
maildrop: authlib: logname=testcreate@example.net, home=/home/vmail, mail=/home/vmail/example.net/testcreate@example.net/
maildrop: Changing to /home/vmail

Message start at 0 bytes, envelope sender=testcreate@example.net
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized string: "SHELL"
Tokenized =
Tokenized string: "/bin/bash"
Tokenized ;
Tokenized string: "EXTENSION"
Tokenized =
Tokenized string: "$1"
Tokenized ;
Tokenized string: "RECIPIENT"
Tokenized =
Tokenized tolower
Tokenized (
Tokenized string: "$2"
Tokenized )
Tokenized ;
Tokenized string: "HOME"
Tokenized =
Tokenized string: "/home/vmail"
Tokenized ;
Tokenized string: "USER"
Tokenized =
Tokenized string: "$3"
Tokenized ;
Tokenized string: "HOST"
Tokenized =
Tokenized string: "$4"
Tokenized ;
Tokenized string: "SENDER"
Tokenized =
Tokenized string: "$5"
Tokenized ;
Tokenized string: "DEFAULT"
Tokenized =
Tokenized string: "$HOME/$HOST/$USER/"
Tokenized ;
Tokenized string: "MAILDIR"
Tokenized =
Tokenized string: "$HOME/$HOST/$USER/"
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized logfile
Tokenized string: "/var/log/maildroprc.log"
Tokenized ;
Tokenized string: "VERBOSE"
Tokenized =
Tokenized string: "9"
Tokenized ;
Tokenized log
Tokenized string: "Markers: ---------------------------------------------"
Tokenized ;
Tokenized log
Tokenized string: " (**) from config file, (II) informational, (WW) warning"
Tokenized ;
Tokenized log
Tokenized string: "--------------------------------------------------------"
Tokenized ;
Tokenized log
Tokenized string: ""
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized string: "BPM"
Tokenized =
Tokenized string: "-----BEGIN PGP MESSAGE-----"
Tokenized ;
Tokenized string: "EPM"
Tokenized =
Tokenized string: "-----END PGP MESSAGE-----"
Tokenized ;
Tokenized string: "BPS"
Tokenized =
Tokenized string: "-----BEGIN PGP SIGNATURE-----"
Tokenized ;
Tokenized string: "EPS"
Tokenized =
Tokenized string: "-----END PGP SIGNATURE-----"
Tokenized ;
Tokenized ;
Tokenized if
Tokenized (
Tokenized !
Tokenized regexp: /^Content-Type: message/
Tokenized &&
Tokenized !
Tokenized regexp: /^Content-Type: multipart/
Tokenized &&
Tokenized !
Tokenized regexp: /^Content-Type: application\/pgp/
Tokenized )
Tokenized ;
Tokenized {
Tokenized ;
Tokenized if
Tokenized (
Tokenized regexp: /^$BPM/:b
Tokenized &&
Tokenized regexp: /^$EPM/:b
Tokenized )
Tokenized ;
Tokenized xfilter
Tokenized string: "reformail -A 'Content-Type: application/pgp; format=text; x-action=encrypt'"
Tokenized ;
Tokenized ;
Tokenized if
Tokenized (
Tokenized regexp: /^$BPS/:b
Tokenized &&
Tokenized regexp: /^$EPS/:b
Tokenized )
Tokenized ;
Tokenized xfilter
Tokenized string: "reformail -A 'Content-Type: application/pgp; format=text; x-action=sign'"
Tokenized ;
Tokenized }
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized if
Tokenized (
Tokenized regexp: /^--($|[ ]{2,}^)/:b
Tokenized )
Tokenized ;
Tokenized {
Tokenized ;
Tokenized xfilter
Tokenized string: "sed -r 's/^--($|[ ]{2,}^)/-- /'"
Tokenized ;
Tokenized log
Tokenized string: "(II) Sig Dashes corrected"
Tokenized ;
Tokenized }
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized ;
Tokenized string: `test -e $HOME/$HOST`
Tokenized ;
Tokenized if
Tokenized (
Tokenized string: "$RETURNCODE"
Tokenized !=
Tokenized string: "0"
Tokenized )
Tokenized ;
Tokenized {
Tokenized ;
Tokenized string: `/bin/mkdir $HOME/$HOST`
Tokenized ;
Tokenized string: `/bin/chown vmail.vmail $HOME/$HOST`
Tokenized ;
Tokenized string: `/bin/chmod 0700 $HOME/$HOST`
Tokenized ;
Tokenized }
Tokenized ;
Tokenized ;
Tokenized string: `test -e $HOME/$HOST/$USER`
Tokenized ;
Tokenized if
Tokenized (
Tokenized string: "$RETURNCODE"
Tokenized !=
Tokenized string: "0"
Tokenized )
Tokenized ;
Tokenized {
Tokenized ;
Tokenized string: `/usr/bin/maildirmake $HOME/$HOST/$USER`
Tokenized ;
Tokenized string: `/bin/chown -R vmail.vmail $HOME/$HOST`
Tokenized ;
Tokenized string: `/bin/chmod -R 0700 $HOME/$HOST`
Tokenized ;
Tokenized }
Tokenized ;
Tokenized ;
Tokenized string: `test -r $HOME/mailfilters/$HOST`
Tokenized ;
Tokenized if
Tokenized (
Tokenized string: "$RETURNCODE"
Tokenized ==
Tokenized string: "0"
Tokenized )
Tokenized ;
Tokenized {
Tokenized ;
Tokenized log
Tokenized string: "(==) Including $HOME/mailfilters/$HOST"
Tokenized ;
Tokenized include
Tokenized string: "$HOME/mailfilters/$HOST"
Tokenized ;
Tokenized }
Tokenized ;
Tokenized eof
/etc/maildroprc(7): SHELL="/bin/bash"
/etc/maildroprc(8): EXTENSION=""
/etc/maildroprc(9): RECIPIENT=""
/etc/maildroprc(10): HOME="/home/vmail"
/etc/maildroprc(11): USER=""
/etc/maildroprc(12): HOST=""
/etc/maildroprc(13): SENDER=""
/etc/maildroprc(14): DEFAULT="/home/vmail///"
/etc/maildroprc(15): MAILDIR="/home/vmail///"
/etc/maildroprc(20): Opening logfile /var/log/maildroprc.log
/etc/maildroprc(21): VERBOSE="9"


from log file


Jul 18 15:19:43 demo authdaemond: SQL query: SELECT username, password, "", 5000, 5000, "/home/vmail", CONCAT("/home/vmail/",maildir) , concat(quota,'S'), name, "" FROM mailbox WHERE username = 'testcreate@example.net'
Jul 18 15:19:43 demo authdaemond: Authenticated: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/home/vmail, address=testcreate@example.net, fullname=testcreate, maildir=/home/vmail/example.net/testcreate@example.net/, quota=0S, options=<null>
maildrop[6612]: Unable to open mailbox.

maildroprc file

#Global maildrop filter file
#DEFAULT="$HOME/.maildir/"

#
# Define variables
#
SHELL="/bin/bash"
EXTENSION="$1"
RECIPIENT=tolower("$2")
HOME="/home/vmail"
USER="$3"
HOST="$4"
SENDER="$5"
DEFAULT="$HOME/$HOST/$USER/"
MAILDIR="$HOME/$HOST/$USER/"

#DEFAULT="$HOME/Maildir/"
#MAILDIR="$HOME/Maildir/"

logfile "/var/log/maildroprc.log"
VERBOSE="9"
log "Markers: ---------------------------------------------"
log " (**) from config file, (II) informational, (WW) warning"
log "--------------------------------------------------------"
log ""


################################################## ####################
#
# Adding missing headers for PGP/MIME
#

BPM="-----BEGIN PGP MESSAGE-----"
EPM="-----END PGP MESSAGE-----"
BPS="-----BEGIN PGP SIGNATURE-----"
EPS="-----END PGP SIGNATURE-----"

if (!/^Content-Type: message/ && !/^Content-Type: multipart/ \
&& !/^Content-Type: application\/pgp/)
{
if (/^$BPM/:b && /^$EPM/:b)
xfilter "reformail -A 'Content-Type: application/pgp; format=text; \
x-action=encrypt'"

if (/^$BPS/:b && /^$EPS/:b)
xfilter "reformail -A 'Content-Type: application/pgp; format=text; \
x-action=sign'"
}


################################################## ###################
#
# Correcting wrong signature dashes
#

if (/^--($|[ ]{2,}^)/:b)
{
xfilter "sed -r 's/^--($|[ ]{2,}^)/-- /'"
log "(II) Sig Dashes corrected"
}

# Include any rules set up for the user - this gives the
# administrator a way to override the domain's mailfilter file
#
# this is also the "suggested" way to set individual values
# for maildrop such as quota. (why do you need quota on your own PC?)
#
`test -e $HOME/$HOST`
if ( $RETURNCODE != 0 )
{
`/bin/mkdir $HOME/$HOST`
`/bin/chown vmail.vmail $HOME/$HOST`
`/bin/chmod 0700 $HOME/$HOST`
}

`test -e $HOME/$HOST/$USER`
if ( $RETURNCODE != 0 )
{
`/usr/bin/maildirmake $HOME/$HOST/$USER`
`/bin/chown -R vmail.vmail $HOME/$HOST`
`/bin/chmod -R 0700 $HOME/$HOST`
}

`test -r $HOME/mailfilters/$HOST`
if( $RETURNCODE == 0 )
{
log "(==) Including $HOME/mailfilters/$HOST"
include $HOME/mailfilters/$HOST
}

falko
19th July 2008, 23:34
This comment might help: http://www.howtoforge.com/virtual-users-and-domains-postfix-courier-mysql-centos5.1-p5#comment-4470

tecstream
21st July 2008, 21:04
Falco,

Thanks for the link got it straightened out now. Does the .Junk folder work with Mailscanner in place ??


Tec

mkdir=/bin/mkdir
rmdir=/bin/rmdir
MAILDIR=$DEFAULT

# make the user's mail directory if it doesn't exist
`test -e $MAILDIR`
if ($RETURNCODE != 0)
{
`$mkdir -p $MAILDIR`
`$rmdir $MAILDIR`
`$maildirmake $MAILDIR`
}

# make the .Junk folder if it doesn't exist
JUNK_FOLDER=.Junk
_JUNK_DEST=$MAILDIR/$JUNK_FOLDER/
`test -d $_JUNK_DEST`
if ($RETURNCODE != 0 )
{
`$maildirmake $_JUNK_DEST`
#auto subscribe. the following works for courier-imap
`echo INBOX.Junk >> $MAILDIR/courierimapsubscribed`
}

if (/^X-Spam-Flag:.*YES/)
{
exception {
to $DEFAULT/.Junk/
}
}

falko
22nd July 2008, 15:27
Falco,

Thanks for the link got it straightened out now. Does the .Junk folder work with Mailscanner in place ??


Haven't tried this so I can't tell...

eliufoo
22nd July 2008, 19:18
hey, I have the same setup, probably from the same tutorial but, I can't get my setup to work.

please assist.

Elly

tecstream
22nd July 2008, 20:29
Elly,


Having just gotten this to work I will gladly try to help.


my maildroprc file is listed below if this is not enough please let me know exactly what is and is not working along with the main.cf and master.cf and any other configuration files that you think will help.

Tec

#SHELL="/bin/sh"
VERBOSE=5

# commands and variables for making the mail directories
maildirmake=/usr/lib/courier-imap/bin/maildirmake
mkdir=/bin/mkdir
rmdir=/bin/rmdir
MAILDIR=$DEFAULT

# make the user's mail directory if it doesn't exist
`test -e $MAILDIR`
if ($RETURNCODE != 0)
{
`$mkdir -p $MAILDIR`
`$rmdir $MAILDIR`
`$maildirmake $MAILDIR`
}

# make the .Junk folder if it doesn't exist
JUNK_FOLDER=.Junk
_JUNK_DEST=$MAILDIR/$JUNK_FOLDER/
`test -d $_JUNK_DEST`
if ($RETURNCODE != 0 )
{
`$maildirmake $_JUNK_DEST`
#auto subscribe. the following works for courier-imap
`echo INBOX.Junk >> $MAILDIR/courierimapsubscribed`
}

if (/^X-Spam-Flag:.*YES/)
{
exception {
to $DEFAULT/.Junk/
}
}

eliufoo
22nd July 2008, 21:22
Firstly, Thank you for the help. :-)

Ok. If i use virtual as my delivery mechanism instead of maildrop, the maildir are created.

postfix -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
header_checks = regexp:/etc/postfix/header_checks
inet_interfaces = all
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = example.com
myhostname = mail.example.com
mynetworks = $config_directory/mynetworks
relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf
smtp_use_tls = no
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject _non_fqdn_hostname,reject_non_fqdn_sender,reject_n on_fqdn_recipient,reject_unauth_destination,reject _unauth_pipelining,reject_invalid_hostname,reject_ rbl_client opm.blitzed.org,reject_rbl_client list.dsbl.org,reject_rbl_client bl.spamcop.net,reject_rbl_client sbl-xbl.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = smptd
smtpd_sasl_security_options = noanonymous
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /usr/local/ssl/mail.example.com.crt
smtpd_tls_key_file = /usr/local/ssl/mail.example.com.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:/etc/postfix/tls_smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:1001
virtual_mailbox_base = /var/vmail2
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 1001
virtual_transport = maildrop
virtual_uid_maps = static:1001


/etc/postfix/master.cf

# ================================================== ========================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ================================================== ========================
smtp inet n - n - - smtpd
567 inet n - n - - smtpd
#submission inet n - n - - smtpd
# -o smtpd_enforce_tls=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticate d,reject
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes

#628 inet n - n - - qmqpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - n 300 1 oqmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
smtp unix - - n - - smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay unix - - n - - smtp
-o fallback_relay=
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
#
# ================================================== ==================
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -w 90 -d ${recipient}
#
# ================================================== ==================



#Added By Eliufoo C. Mahinda
# VIRTUAL VACATION
#
vacation unix - n n - - pipe
flags=DRhu user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}

I'm also using postfixadmin to add users. could the /usr/sbin/maildirmake.sh need correction too?

#!/bin/bash
echo "The begining" >> /tmp/shell-test
set -e
mail_home="/var/vmail2"
if [ ! -d $mail_home/$1 ] ; then
mkdir $mail_home/$1
chown -R vmail:vmail $mail_home/$1
chmod -R 700 $mail_home/$1
#echo "$mail_home/$1 CREATED"
fi
if [ -d $mail_home/$1 ] ; then
cd "$mail_home/$1"
maildirmake $2
#echo "$mail_home/$1/$2 CREATED"
maildirmake -q "$3S" $2
#echo "$3S $2 QUOTA CREATED"
chown -R vmail:vmail $mail_home/$1/$2
chmod -R 700 $mail_home/$1/$2
fi

tecstream
22nd July 2008, 21:59
Elly,


A copy and paste error I also had is in your main.cf

smtpd_sasl_path = smptd >>>>>>>>>>>>smtp


I am assuming this is your default home is the group and owner vmail ??
permission 0700 ??

mail_home="/var/vmail2"

Elly,

Can you run this command and send the reply

maildrop -V 9 -d someuser@example.net

Tec


I have one line different in my master.cf but it should make no real difference for maildir auto create.

smtps inet n - n - - smtpd -v
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticate d,reject

Tec BRB

eliufoo
22nd July 2008, 22:37
IT WORKING!!!!!! :-)

I changed the typo error and mails were still not been delivered. Then I changed the directory permission from 600 to 700 and it worked.

Reverting back to directory of permission of 600, I get the same error again [maildrop can not change to directory]

One more thing, how can i have user directories in /var/vmail2/domain.tld/user/ form?
My current directory are created like /var/vmail2/user@domain.tld.

/etc/authlib/authmysqlrc
MYSQL_MAILDIR_FIELD CONCAT("/var/vmail2/",maildir)

eliufoo
25th July 2008, 13:17
One more thing, how can i have user directories in /var/vmail2/domain.tld/user/ form?
My current directory are created like /var/vmail2/user@domain.tld.

I got this resolved too :-) make the following changes on your postfixadmin/config.inc.php

$CONF['domain_path'] = 'YES'
$CONF['domain_in_mailbox'] = 'NO';

Another problem bites the dust.
Thanks for the help guys.

Elly