Debian with Altermime Problems

Discussion in 'Installation/Configuration' started by wannannaw, Aug 13, 2008.

  1. wannannaw

    wannannaw New Member

    I've just installed altermim in to our postfix e-mail server. And I'm seeing problems when I send out e-mails. Here's the rundown. I'm sending through thunderbird and outlook. When i send to HTML Only I don't recieve the disclaimer, when I send to txt I recieve the text disclaimer, when I send to html and text I see the html disclaimer (or text). But when I send HTML only it doesn't include the disclaimer html in the source anywhere like it's not being added. I did notice something weird in the headers. This is the html and txt content type (which works)
    Content-Type: multipart/alternative;
    boundary="------------040308060102020907020202"

    This is the html content type (which doesn't)
    Content-Type: text/html; charset=ISO-8859-1

    Here's my setup. Maybe i'm overlooking something simple but please help.

    /etc/postfix/disclaimer

    #!/bin/sh
    # Localize these.
    INSPECT_DIR=/var/spool/filter
    SENDMAIL=/usr/sbin/sendmail
    disc_flag=0
    ###########changed from original script########
    DISCLAIMER_ADDRESSES=/etc/postfix/disclaimer_addresses
    #######end#########
    # Exit codes from <sysexits.h>
    EX_TEMPFAIL=75
    EX_UNAVAILABLE=69


    # Clean up when done or when aborting.
    trap "rm -f in.$$" 0 1 2 3 15

    # Start processing.
    cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
    $EX_TEMPFAIL; }

    cat >in.$$ || { echo cannot save mail to file; exit $EX_TEMPFAIL; }

    ########change from original script#########
    #obtain from address
    to_address=$(grep "To:" in.$$ | cut -d ":" -f 2|sed 's/, / /g')
    SENDER=$(echo $* | awk '{print $2}' | tr [A-Z] [a-z])

    for i in $to_address
    do
    to_dom=$(echo $i |cut -d "@" -f 2)

    #if [ $(grep -ivc $to_dom ${DISCLAIMER_ADDRESSES}) -ge 1 ]; then

    if [ $(echo $SENDER | grep -cie '[email protected]$' -cie '[email protected]$' -cie '[email protected]$') -gt 0 ]; then
    if [ $disc_flag -eq 0 ]; then
    disc_flag=1

    /usr/local/bin/altermime --input=in.$$ \
    --disclaimer=/etc/postfix/filter/disclaimer.txt \
    --disclaimer-html=/etc/postfix/filter/disclaimer.htm \
    --htmltoo \
    --force-for-bad-html \
    --verbose \
    --log-syslog \
    --xheader="X-Copyrighted-Material: Please visit http://www.company.com/privacy.htm" || \
    { echo Message content rejected; exit $EX_UNAVAILABLE; }

    fi
    fi
    #fi
    done
    #####end#######

    $SENDMAIL -i "$@" < in.$$

    exit $?

    relevent master.cf file

    smtp inet n - - - - smtpd
    -o content_filter=spamassassin
    -o content_filter=dfilt:

    dfilt unix - n n - - pipe
    flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}
     
  2. maremester

    maremester New Member

    "disclaimer" script

    "disclaimer" script:

    Code:
    #!/bin/sh
    INSPECT_DIR=/var/spool/filter
    SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
    FOLDER_DISCLAIMER=/opt/zimbra/postfix/conf
    
    # Exit codes from <sy***its.h>
    EX_TEMPFAIL=75
    EX_UNAVAILABLE=69
    
    # Clean up when done or when aborting.
    trap "rm -f in.$$" 0 1 2 3 15
    
    # Start processing.
    cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
    
    TEXT_DISCLAIMER=`grep "[a|A-z|Z]" ${FOLDER_DISCLAIMER}/disclaimer.txt | grep -v "_" | tail -2 | head -1`
    
    cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }
    
    nohup grep "${TEXT_DISCLAIMER}" in.$$ > /dev/null 2>&1
    
    # Extract SENDTO Address(ex. "user@other_domain.com")
    to_address=`grep -m 1 "To:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1`
    
    # Extract from SENDTO address only DOMAIN name(ex. "other_domain.com")
    to_dom=`echo $to_address |cut -d "@" -f 2`
    
    our_domain="YOURDOMAIN.COM"
    
    # If OTHER_DOMAIN.COM(SENDTO domain) is not YOURDOMAIN.COM add disclaimer
    # means that add disclaimer only for outgoing mail
    # for internal mail you will not have disclaimer
    if [ $to_dom != $our_domain ]; then
            /usr/bin/altermime --input=in.$$ \
                    --disclaimer=${FOLDER_DISCLAIMER}/disclaimer.txt \
                    --disclaimer-html=${FOLDER_DISCLAIMER}/disclaimer.html \
                    --xheader="X-Copyrighted-Material: Please visit http://www.company.com/privacy.htm" || \
                    { echo Message content rejected; exit $EX_UNAVAILABLE; }
    fi
    
    $SENDMAIL -i "$@" < in.$$
    
    exit $?
    
    
    For more info read:
    http://www.zimbra.com/forums/administrators/4747-solved-adding-disclaimer-footer-4.html
     

Share This Page