Virtual Users With Postfix, PostfixAdmin, Courier, Mailscanner,Mailwatch CentOS 5.2

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

  1. tecstream

    tecstream New Member

    I have set up a development server and have it running now with mail flowing in and out the problem I have is a lack of understanding on the auto create of mail folders and Maildir in general. as of now the mail goes into a system users account and I want it to flow to the virtual users folder I created in /home/vmail perfection would be /home/vmail/domainname/username/. I have tried multiple things via these forums to get this to happen to no avail.

    Any help would be appreciated and a general explanation with it even better

    TIA -----and sorry for such a long post with configs just figured it would save time

    Tec

    postconf -n

    alias_database = hash:/etc/aliases
    alias_maps = hash:/etc/aliases
    broken_sasl_auth_clients = yes
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/libexec/postfix
    debug_peer_level = 3
    debug_peer_list = 127.0.0.1
    header_checks = regexp:/etc/postfix/header_checks
    home_mailbox = Maildir/
    html_directory = no
    inet_interfaces = all
    local_recipient_maps = proxy:unix:passwd.byname $alias_maps
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    mydestination = $myhostname, localhost.$mydomain, localhost
    mydomain = example.net
    myhostname = example.net
    mynetworks = $config_directory/mynetworks
    newaliases_path = /usr/bin/newaliases.postfix
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
    relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf
    sample_directory = /usr/share/doc/postfix-2.3.3/samples
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    smtp_use_tls = no
    smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_non_fqdn_hostname,reject_non_fqdn_sender,reject_non_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/example.net.crt
    smtpd_tls_key_file = /usr/local/ssl/example.net.key
    smtpd_tls_loglevel = 2
    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
    unknown_local_recipient_reject_code = 550
    virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
    virtual_create_maildirsize = yes
    virtual_gid_maps = static:5000
    virtual_mailbox_base = /home/vmail
    virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
    virtual_mailbox_limit = 51200000
    virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
    virtual_mailbox_limit_override = yes
    virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
    virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
    virtual_minimum_uid = 5000
    virtual_transport = maildrop
    virtual_uid_maps = static:5000

    mysql_relay_domains_maps.cf
    user = postfix
    password = postfix
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'

    mysql_virtual_alias_maps.cf
    user = postfix
    password = postfix
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT goto FROM alias WHERE address='%s' AND active = 1

    mysql_virtual_domains_maps.cf
    user = postfix
    password = postfix
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT domain FROM domain WHERE domain='%s'
    #optional query to use when relaying for backup MX
    #query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '0' and active = '1'

    mysql_virtual_mailbox_limit_maps.cf
    user = postfix
    password = postfix
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT quota FROM mailbox WHERE username='%s'


    mysql_virtual_mailbox_maps.cf
    user = postfix
    password = postfix
    hosts = 127.0.0.1
    dbname = postfix
    query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1



    Master.cf


    #
    # ==========================================================================
    # service type private unpriv chroot wakeup maxproc command + args
    # (yes) (yes) (yes) (never) (100)
    # ==========================================================================
    smtp inet n - n - - smtpd -v
    #submission inet n - n - - smtpd
    # -o smtpd_enforce_tls=yes
    # -o smtpd_sasl_auth_enable=yes
    # -o smtpd_client_restrictions=permit_sasl_authenticated,reject
    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
    #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
    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
    #
    # ====================================================================
    # Interfaces to non-Postfix software. Be sure to examine the manual
    # pages of the non-Postfix software to find out what options it wants.
    #
    # Many of the following services use the Postfix pipe(8) delivery
    # agent. See the pipe(8) man page for information about ${recipient}
    # and other message envelope options.
    # ====================================================================
    #
    # 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 -d ${recipient}
    #
    # The Cyrus deliver program has changed incompatibly, multiple times.
    #
    old-cyrus unix - n n - - pipe
    flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
    # Cyrus 2.1.5 (Amos Gouaux)
    # Also specify in main.cf: cyrus_destination_recipient_limit=1
    cyrus unix - n n - - pipe
    user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
    #
    # See the Postfix UUCP_README file for configuration details.
    #
    uucp unix - n n - - pipe
    flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
    #
    # Other external delivery methods.
    #
    ifmail unix - n n - - pipe
    flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
    bsmtp unix - n n - - pipe
    flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient


    maildirmake.sh

    #!/bin/bash
    MAILDIRMAKE=/usr/lib/courier-imap/bin/maildirmake

    set -e
    mail_home="/home/vmail"
    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


    postfixadmin create-mailbox.php


    <?php
    /**
    * Postfix Admin
    *
    * LICENSE
    * This source file is subject to the GPL license that is bundled with
    * this package in the file LICENSE.TXT.
    *
    * Further details on the project are available at :
    * http://www.postfixadmin.com or http://postfixadmin.sf.net
    *
    * @version $Id: create-mailbox.php 250 2007-12-02 13:59:33Z GingerDog $
    * @license GNU GPL v2 or later.
    *
    * File: create-mailbox.php
    * Responsible for allowing for the creation of mail boxes
    *
    * @version $Id: create-mailbox.php 250 2007-12-02 13:59:33Z GingerDog $
    * @license GNU GPL v2 or later.
    *
    * Template Variables:
    *
    * tMessage
    * tUsername
    * tName
    * tQuota
    * tDomain
    *
    * Form POST \ GET Variables:
    *
    * fUsername
    * fPassword
    * fPassword2
    * fName
    * fQuota
    * fDomain
    * fActive
    * fMail
    */

    require_once('common.php');

    authentication_require_role('admin');
    $SESSID_USERNAME = authentication_get_username();
    if(authentication_has_role('global-admin')) {
    $list_domains = list_domains ();
    }
    else {
    $list_domains = list_domains_for_admin($SESSID_USERNAME);
    }


    $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text'];
    $pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text'];
    $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text'];

    if ($_SERVER['REQUEST_METHOD'] == "GET")
    {
    $fDomain = $list_domains[0];
    if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);

    if(!in_array($fDomain, $list_domains)) {
    die("Invalid domain name selected, or you tried to select a domain you are not an admin for");
    }
    $tDomain = $fDomain;
    $result = db_query ("SELECT * FROM $table_domain WHERE domain='$fDomain'");
    if ($result['rows'] == 1)
    {
    $row = db_array ($result['result']);
    $tQuota = $row['maxquota'];
    }
    }

    if ($_SERVER['REQUEST_METHOD'] == "POST")
    {

    if (isset ($_POST['fUsername']) && isset ($_POST['fDomain'])) $fUsername = escape_string ($_POST['fUsername']) . "@" . escape_string ($_POST['fDomain']);
    $fUsername = strtolower ($fUsername);
    if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']);
    if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']);
    isset ($_POST['fName']) ? $fName = escape_string ($_POST['fName']) : $fName = "";
    if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
    isset ($_POST['fQuota']) ? $fQuota = intval($_POST['fQuota']) : $fQuota = 0;
    isset ($_POST['fActive']) ? $fActive = escape_string ($_POST['fActive']) : $fActive = "1";
    if (isset ($_POST['fMail'])) $fMail = escape_string ($_POST['fMail']);


    if ( (!check_owner ($SESSID_USERNAME, $fDomain)) && (!authentication_has_role('global-admin')) )
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1'];
    }

    if (!check_mailbox ($fDomain))
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3'];
    }

    if (empty ($fUsername) or !check_email ($fUsername))
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1'];
    }

    if (empty ($fPassword) or empty ($fPassword2) or ($fPassword != $fPassword2))
    {
    if (empty ($fPassword) and empty ($fPassword2) and $CONF['generate_password'] == "YES")
    {
    $fPassword = generate_password ();
    }
    else
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error'];
    }
    }

    if ($CONF['quota'] == "YES")
    {
    if (!check_quota ($fQuota, $fDomain))
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error'];
    }
    }

    $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
    if ($result['rows'] == 1)
    {
    $error = 1;
    $tUsername = escape_string ($_POST['fUsername']);
    $tName = $fName;
    $tQuota = $fQuota;
    $tDomain = $fDomain;
    $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2'];
    }

    if ($error != 1)
    {
    $password = pacrypt ($fPassword);

    if ($CONF['domain_path'] == "YES")
    {
    if ($CONF['domain_in_mailbox'] == "YES")
    {
    $maildir = $fDomain . "/" . $fUsername . "/";
    }
    else
    {
    $maildir = $fDomain . "/" . escape_string (strtolower($_POST['fUsername'])) . "/";
    }
    }
    else
    {
    $maildir = $fUsername . "/";
    }

    if (!empty ($fQuota))
    {
    $quota = multiply_quota ($fQuota);
    }
    else
    {
    $quota = 0;
    }

    if ($fActive == "on")
    {
    $sqlActive = db_get_boolean(True);
    }
    else
    {
    $sqlActive = db_get_boolean(False);
    }
    if ('pgsql'==$CONF['database_type'])
    {
    db_query('BEGIN');
    }

    $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$fDomain',NOW(),NOW(),'$sqlActive')");
    if ($result['rows'] != 1)
    {
    $tDomain = $fDomain;
    $tMessage = $PALANG['pAlias_result_error'] . "<br />($fUsername -> $fUsername)</br />";
    }

    /*
    # TODO: The following code segment is from admin/create-mailbox.php. To be compared/merged with the code from /create-mailbox.php.
    Lines starting with /* were inserted to keep this section in commented mode.


    if ($result['rows'] != 1)
    {
    $tDomain = $fDomain;
    $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />";
    }
    else
    {

    $error=TRUE; // Being pessimistic
    if (mailbox_postcreation($fUsername,$fDomain,$maildir))
    {
    if ('pgsql'==$CONF['database_type'])
    {
    $result=db_query("COMMIT");

    /* should really not be possible: */
    /*
    if (!$result) die('COMMIT-query failed.');
    }
    $error=FALSE;
    } else {
    $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />";
    if ('pgsql'==$CONF['database_type'])
    {
    $result=db_query("ROLLBACK");

    /* should really not be possible: */
    /*
    if (!$result) die('ROLLBACK-query failed.');
    } else {
    /*
    When we cannot count on transactions, we need to move forward, despite
    the problems.
    */
    /*
    $error=FALSE;
    }
    }


    if (!$error)
    {
    db_log ($CONF['admin_email'], $fDomain, 'create_mailbox', $fUsername);

    */

    /*
    TODO: this is the start of /create-mailbox code segment that was originally used in /create-mailbox.php instead
    of the above from admin/create-mailbox.php.
    To be compared / merged.
    */

    $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$sqlActive')");
    if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir))
    {
    $tDomain = $fDomain;
    $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />";
    db_query('ROLLBACK');
    }
    else
    {
    db_query('COMMIT');
    db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername");




    /*
    TODO: this is the end of /create-mailbox.php code segment
    */
    $tDomain = $fDomain;

    if (create_mailbox_subfolders($fUsername,$fPassword))
    {
    $tMessage = $PALANG['pCreate_mailbox_result_success'] . "<br />($fUsername";
    } else {
    $tMessage = $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />($fUsername";
    }

    if ($CONF['generate_password'] == "YES")
    {
    $tMessage .= " / $fPassword)</br />";
    }
    else
    {
    if ($CONF['show_password'] == "YES")
    {
    $tMessage .= " / $fPassword)</br />";
    }
    else
    {
    $tMessage .= ")</br />";
    }
    }

    $tQuota = $CONF['maxquota'];

    if ($fMail == "on")
    {
    $fTo = $fUsername;
    $fFrom = $SESSID_USERNAME;
    $fHeaders = "To: " . $fTo . "\n";
    $fHeaders .= "From: " . $fFrom . "\n";

    $fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text']) . "\n";
    $fHeaders .= "MIME-Version: 1.0\n";
    $fHeaders .= "Content-Type: text/plain; charset=utf-8\n";
    $fHeaders .= "Content-Transfer-Encoding: 8bit\n";

    $fHeaders .= $CONF['welcome_text'];

    if (!smtp_mail ($fTo, $fFrom, $fHeaders))
    {
    $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />";
    }
    else
    {
    $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />";
    }
    }
    }
    }
    }

    include ("templates/header.php");
    include ("templates/menu.php");
    include ("templates/create-mailbox.php");
    include ("templates/footer.php");

    system("sudo /usr/sbin/maildirmake.sh ".$fDomain." ".$fUsername. " ". $quota);
    db_log ($SESSID_USERNAME, $fDomain, "$fUsername");

    /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */


    ?>
     
  2. falko

    falko Super Moderator Howtoforge Staff

    You must remove that domain from the mydestination parameter in your main.cf, and the left part of the email address (before @) must not exist as a system user.
     
  3. tecstream

    tecstream New Member

    Falco,

    Thanks for the assistance!!

    I had not noticed that the $myhostname was an issue. I also was not aware that one could not have a system account. Even so I do not get a creation of a Maildir automatically. Instead it created a vmail folder in my /home/vmail not what I expected.

    Tec


    maillog attempt new account


    Jul 16 13:40:37 demo authdaemond: received userid lookup request: [email protected]
    Jul 16 13:40:37 demo authdaemond: authmysql: trying this module
    Jul 16 13:40:37 demo authdaemond: authmysqllib: connected. Versions: header 50045, client 50045, server 50045
    Jul 16 13:40:37 demo authdaemond: SQL query: SELECT username, password, "", 5000, 5000, "/home/vmail", CONCAT("/home/vmail/",maildir) , concat(quota,'S'), name, "" FROM mailbox WHERE username = '[email protected]'
    Jul 16 13:40:37 demo authdaemond: Authenticated: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/home/vmail, [email protected], fullname=MarkMac, maildir=/home/vmail/example.net/[email protected]/, quota=0S, options=<null>
    Jul 16 13:40:37 demo authdaemond: Authenticated: clearpasswd=<null>, passwd=$1$954a669d$zcDxyF.55ZLtPu9rJHLU1/
    Jul 16 13:40:37 demo maildrop[5059]: Unable to open mailbox.
    Jul 16 13:40:37 demo postfix/pipe[5058]: 436AEA0259: to=<[email protected]>, relay=maildrop, delay=3370, delays=3367/1.3/0/1.3, dsn=4.3.0, status=deferred (temporary failure. Command output: /usr/bin/maildrop: Unable to open mailbox. )
     
  4. tecstream

    tecstream New Member

    I found that the creation of the vmail folder was related to an incorrect maildroprc file. (listed below) I have fixed that file but still I do not get an auto created mail directory. Also even if I create the file via maildirmake I still get the unable to open the mailbox error (also shown below)

    vmail is the owner and group and files permissions are 0700

    maildroprc old 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/vmail/$HOST/$USER"
    MAILDIR="$HOME/vmail/$HOST/$USER"

    logfile "/var/log/maildroprc.log"
    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/vmail/$HOST`
    if ( $RETURNCODE != 0 )
    {
    `/bin/mkdir $HOME/vmail/$HOST`
    `/bin/chown vmail.vmail $HOME/vmail/$HOST`
    `/bin/chmod 0700 $HOME/$HOST`
    }

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

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

    maildroprc new 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"

    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
    }



    maillog

    Jul 16 16:05:05 demo authdaemond: Authenticated: clearpasswd=<null>, passwd=$1$954a669d$zcDxyF.55ZLtPu9rJHLU1/
    Jul 16 16:05:05 demo maildrop[7982]: Unable to open mailbox.
    Jul 16 16:05:05 demo postfix/pipe[7981]: 436AEA0259: to=<[email protected]>, relay=maildrop, delay=12038, delays=12038/0.05/0/0.07, dsn=4.3.0, status=deferred (temporary failure. Command output: /usr/bin/maildrop: Unable to open mailbox. )
     

Share This Page