Maildrop Postfixadmin create mail directories

Discussion in 'HOWTO-Related Questions' started by tecstream, Jul 18, 2008.

  1. tecstream

    tecstream New Member

    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
    }
     
  2. falko

    falko Super Moderator

  3. tecstream

    tecstream New Member

    Maildroprc auto create mail directories script

    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/
    }
    }
     
  4. falko

    falko Super Moderator

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

    eliufoo New Member

    hey, I have the same setup, probably from the same tutorial but, I can't get my setup to work.

    please assist.

    Elly
     
  6. tecstream

    tecstream New Member

    maildroprc configuration

    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/
    }
    }
     
  7. eliufoo

    eliufoo New Member

    Firstly, Thank you for the help. :)

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

    postfix -n

    /etc/postfix/master.cf

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

     
  8. tecstream

    tecstream New Member

    Maildroprc main.cf typo

    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_authenticated,reject

    Tec BRB
     
    Last edited: Jul 22, 2008
  9. eliufoo

    eliufoo New Member

    almost done...

    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
     
  10. eliufoo

    eliufoo New Member

    resolved...

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

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

    Elly
     

Share This Page