Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Hooking in another process or content_filter?

  1. #11
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    14

    Default sendmail

    try
    chown postfix /opt/zimbra/postfix/sbin/sendmail
    chmod u+s /opt/zimbra/postfix/sbin/sendmail

  2. #12
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    Thumbs up

    Quote Originally Posted by marcmac
    try
    chown postfix /opt/zimbra/postfix/sbin/sendmail
    chmod u+s /opt/zimbra/postfix/sbin/sendmail
    Wahoo! Thank you very much marcmac!

  3. #13
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    Question Help!!!

    I spoke too soon! Now the script is stuck in a loop, I tried using zmlmtpinject which seemed to work for local mail only, external mail was not delivered. I modified the script to stop the loop but the mail will not be delivered:

    Code:
    #!/bin/sh
    # System dependent settings
    ALTERMIME=/usr/local/bin/altermime
    ALTERMIME_DIR=/opt/zimbra/filter/scratch
    SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
    # Exit codes of commands invoked by Postfix are expected
    # to follow the conventions defined in <sysexits.h>.
    TEMPFAIL=75
    UNAVAILABLE=69
    # Change in to alterMIME's working directory and
    # notify Postfix if 'cd' fails.
    cd $ALTERMIME_DIR || { echo $ALTERMIME_DIR does not exist; exit $TEMPFAIL; }
    # Clean up when done or when aborting.
    trap "rm -f in.$$" 0 1 2 3 15
    # Write mail to a temporary file
    # Notify Postfix if this fails
    cat >in.$$ || { echo Cannot write to $ALTERMIME_DIR; exit $TEMPFAIL; }
    # Call alterMIME, hand over the message and
    # tell alterMIME what to do with it
    if [ `cat in.$$ | grep X-Copyrighted-Material: | wc -l` -eq 0 ]
    then
    $ALTERMIME --input=in.$$ \
                --disclaimer=/opt/zimbra/filter/disclaimer.txt \
                --disclaimer-html=/opt/zimbra/filter/disclaimer.html \
                --xheader="X-Copyrighted-Material: Please visit http://www.duxarea.com/disclaimer.html" \
                --htmltoo \
                --force-for-bad-html \
                 || \
                { echo Message content rejected; exit $UNAVAILABLE; }
    # Call sendmail to reinject the message into Postfix
    $SENDMAIL "$@" <in.$$
    # Use sendmail's EXIT STATUS to tell Postfix
    # how things went.
    exit $?
    #mv in.$$ /opt/zimbra/postfix/spool/maildrop
    #echo "-r $4 -s $2" > log.$$
    #/opt/zimbra/bin/zmlmtpinject -r "$4" -s "$2"   in.$$
    fi
    echo Message has been through already; exit $UNAVAILABLE;
    In the sample they created a entry in master.cf for the "external interface"
    but I used the 127.0.0.1:10025 entry cause I'm not sure how having the extra entry would effect zimbra
    Mine:
    Code:
    127.0.0.1:10025 inet n  -       n       -       -  smtpd
            -o content_filter=disclaimer:
            -o local_recipient_maps=
            -o virtual_mailbox_maps=
            -o virtual_alias_maps=
            -o relay_recipient_maps=
            -o smtpd_restriction_classes=
            -o smtpd_delay_reject=no
            -o smtpd_client_restrictions=permit_mynetworks,reject
            -o smtpd_helo_restrictions=
            -o smtpd_sender_restrictions=
            -o smtpd_recipient_restrictions=permit_mynetworks,reject
            -o mynetworks_style=host
            -o mynetworks=127.0.0.0/8
            -o strict_rfc821_envelopes=yes  
            -o smtpd_error_sleep_time=0
            -o smtpd_soft_error_limit=1001
            -o smtpd_hard_error_limit=1000
            -o smtpd_client_connection_count_limit=0
            -o smtpd_client_connection_rate_limit=0
            -o receive_override_options=no_header_body_checks,no_unknown_recipient_
    Theirs:
    Code:
    244.233.222.211:smtp inet n  -       n       -       -  smtpd
            -o content_filter=disclaimer:
    Here is the bounce message from Postfix:
    Code:
    This is the Postfix program at host my.zimbradomain.com.
    
    I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.
    
    For further assistance, please send mail to <postmaster>
    
    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.
    
                            The Postfix program
    
    <anonymouse@gmail.com>: service unavailable. Command output: Message has been
        through already

  4. #14
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    14

    Default mail loop

    here's the problem.

    Message path looks like this in zimbra:
    source -> postfix:25 -> amavis:10024 -> postfix:10025 -> zcs:7025 (lmtp).

    Your script adds this:
    source -> postfix:25 -> amavis:10024 -> postfix:10025 -> yourscriptipe -> postfix:25 -> and back to amavis, etc, etc.

    So you'll need to have your script submit back to postfix on another port (10026 is next in the progression) and postfix (in master.cf) will have to have that port set up with no content filter, no alias expansion, etc, etc, to forward on to lmtp.

  5. #15
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    Talking Much Thanks

    Thanks again.

    Here's the whole shabang for anyone else interested (need I say it? "Try at your own risk"):
    First Get altermime and install it on your Zimbra box
    http://www.pldaniels.com/altermime/
    The original putmail.py is located at (no need to download it)
    http://putmail.sourceforge.net/home.html
    Optionally Joe's Own Editor is at
    http://sourceforge.net/projects/joe-editor/
    You might be able to use
    Code:
    yum install joe
    I use joe to edit text files, you can use vi, nano, joe or whatever you like to edit yours

    SSH into your zimbra box As root and download this posts attachment
    Code:
    ssh root@my.zimbrabox.com
    wget http://www.zimbra.com/forums/attachment.php?attachmentid=187&stc=1
    tar -xzvf add_disclaimer_files.tgz
    cp /opt/zimbra/postfix/conf/master.cf /opt/zimbra/postfix/conf/master.cf.bak
    mv master.cf /opt/zimbra/postfix/conf/master.cf
    chown zimbra:zimbra /opt/zimbra/postfix/conf/master.cf
    mv putmail.py /usr/local/bin
    chmod +x /usr/local/bin/putmail.py
    mkdir /opt/zimbra/.putmail
    mv putmailrc /opt/zimbra/.putmail
    joe /opt/zimbra/.putmail/putmailrc
    Change the email address to one of your own email addresses
    /opt/zimbra/.putmail/putmailrc
    Code:
    [config]
    server = localhost
    email = admin@myzimbradomain.com
    port = 10026
    save and exit

    as root
    Code:
    cd ..
    chown zimbra:zimbra /opt/zimbra/.putmail -R
    mkdir /opt/zimbra/filter
    mkdir /opt/zimbra/filter/scratch
    mv add_disclaimer /opt/zimbra/filter
    chmod +x /opt/zimbra/filter/add_disclaimer
    joe /opt/zimbra/filter/add_disclaimer
    Find and Change copyright URL to one of your own

    /opt/zimbra/filter/add_disclaimer
    Code:
    --xheader="X-Copyrighted-Material: Please visit http://www.yourdomain.com/disclaimer.html" \
    Save text and exit

    Now create the global footer files
    as root
    Code:
    joe /opt/zimbra/filter/disclaimer.txt

    /opt/zimbra/filter/disclaimer.txt

    Code:
    Whatever text you want to appear at the bottom of each email
    Save the text and exit

    as root
    Code:
    joe /opt/zimbra/filter/disclaimer.html
    /opt/zimbra/filter/disclaimer.html
    Code:
    Whatever <b>HTML</b> text you want to appear at the bottom of each email
    Save the text and exit

    as root
    Code:
    chown zimbra:zimbra /opt/zimbra/filter -R
    mv zmrestart /opt/zimbra/bin
    chmod +x /opt/zimbra/bin/zmrestart
    chown zimbra:zimbra /opt/zimbra/bin/zmrestart
    su - zimbra
    zmrestart
    If all went well you now have global footers on each email

    Do what you can to support this excellent product. ZCS is too cool!!!
    Attached Files Attached Files

  6. #16
    Join Date
    Mar 2006
    Posts
    1
    Rep Power
    9

    Default Injecting directly to LMTP

    From my content filter, can I directly inject the message into LMTP, instead of submitting it back to postfix on the 10026 port?

  7. #17
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    Default

    Quote Originally Posted by marcmac
    here's the problem.

    Message path looks like this in zimbra:
    source -> postfix:25 -> amavis:10024 -> postfix:10025 -> zcs:7025 (lmtp).

    Your script adds this:
    source -> postfix:25 -> amavis:10024 -> postfix:10025 -> yourscriptipe -> postfix:25 -> and back to amavis, etc, etc.

    So you'll need to have your script submit back to postfix on another port (10026 is next in the progression) and postfix (in master.cf) will have to have that port set up with no content filter, no alias expansion, etc, etc, to forward on to lmtp.
    Basically when I tried to use LMTPInject I ended up in a loop

  8. #18
    Join Date
    Nov 2005
    Posts
    96
    Rep Power
    9

    Default

    Sorry ... this is late... but i tried the script and I am getting the disclaimer to appear from all incoming (from external) and from all outgoing messages.



    Anyway to prevent the incoming message to append the disclaimer??

    adrian
    P/s: Otherwise, it is another great solution for disclaimers!

  9. #19
    Join Date
    Apr 2006
    Posts
    20
    Rep Power
    9

    Default

    Quote Originally Posted by achow
    Anyway to prevent the incoming message to append the disclaimer??
    A quick and dirty way of doings this would be to add a check on the from line, eg...
    Code:
    #!/bin/sh
    # System dependent settings
    ALTERMIME=/usr/local/bin/altermime
    ALTERMIME_DIR=/opt/zimbra/amavisd-new-2.3.3/tmp/
    SENDMAIL=/usr/local/bin/putmail.py
    export HOME=/opt/zimbra
    # Exit codes of commands invoked by Postfix are expected
    # to follow the conventions defined in <sysexits.h>.
    TEMPFAIL=75
    UNAVAILABLE=69
    # Change in to alterMIME's working directory and
    # notify Postfix if 'cd' fails.
    cd $ALTERMIME_DIR || { echo $ALTERMIME_DIR does not exist; exit $TEMPFAIL; }
    # Clean up when done or when aborting.
    trap "rm -f in.$$" 0 1 2 3 15
    # Write mail to a temporary file
    # Notify Postfix if this fails
    cat >in.$$ || { echo Cannot write to $ALTERMIME_DIR; exit $TEMPFAIL; }
    
    # test the message for relevant headers
    cat in.$$ | grep -qE '^From: .*@example.com>?' || { $SENDMAIL "$@" <in.$$ && exit $?; }
    
    # Call alterMIME, hand over the message and
    # tell alterMIME what to do with it
    $ALTERMIME --input=in.$$ \
    			--disclaimer=/opt/zimbra/filter/disclaimer.txt \
    			--disclaimer-html=/opt/zimbra/filter/disclaimer.html \
    			--xheader="X-Copyrighted-Material: Please visit http://www.example.com" \
    			--htmltoo \
    			--force-for-bad-html \
    			 || \
    			{ echo Message content rejected; exit $UNAVAILABLE; }
    # Call sendmail to reinject the message into Postfix
    $SENDMAIL "$@" <in.$$
    # Use sendmail's EXIT STATUS to tell Postfix
    # how things went.
    exit $?
    This could be adapted to do a lookup with zmprov GetAllDomains, or an LDAP lookup, but then it might fit more into the realms of a perl/php/python script.

  10. #20
    Join Date
    Nov 2005
    Posts
    96
    Rep Power
    9

    Default

    Confirmed working with the change in the add_disclaimer file.

    Thanks so much.

    adrian

Similar Threads

  1. Zimbra .pids / service monitoring
    By bin2hex in forum Administrators
    Replies: 24
    Last Post: 04-03-2010, 09:12 PM
  2. Admin login stuck on "Loading..."
    By danfluidmind in forum Installation
    Replies: 9
    Last Post: 07-12-2007, 09:04 AM
  3. 4.53: tomcat is not running
    By michaeln in forum Administrators
    Replies: 41
    Last Post: 06-13-2007, 06:42 PM
  4. tomcat not running / postfix/postqueue errors
    By seravitae in forum Installation
    Replies: 7
    Last Post: 03-10-2007, 07:18 PM
  5. Why is Tomcat shuting down ever nights?
    By trapanator in forum Administrators
    Replies: 2
    Last Post: 11-30-2006, 10:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •