Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 02-14-2006, 01:49 PM
Zimbra Employee
 
Posts: 2,103
Default sendmail

try
chown postfix /opt/zimbra/postfix/sbin/sendmail
chmod u+s /opt/zimbra/postfix/sbin/sendmail
Reply With Quote
  #12 (permalink)  
Old 02-14-2006, 02:02 PM
Senior Member
 
Posts: 53
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!
Reply With Quote
  #13 (permalink)  
Old 02-15-2006, 10:44 AM
Senior Member
 
Posts: 53
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
Reply With Quote
  #14 (permalink)  
Old 02-15-2006, 11:11 AM
Zimbra Employee
 
Posts: 2,103
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.
Reply With Quote
  #15 (permalink)  
Old 02-16-2006, 01:05 PM
Senior Member
 
Posts: 53
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
File Type: tgz add_disclaimer_files.tgz (6.7 KB, 312 views)
Reply With Quote
  #16 (permalink)  
Old 03-26-2006, 01:16 PM
Starter Member
 
Posts: 1
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?
Reply With Quote
  #17 (permalink)  
Old 03-26-2006, 03:13 PM
Senior Member
 
Posts: 53
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
Reply With Quote
  #18 (permalink)  
Old 05-04-2006, 08:50 PM
Loyal Member
 
Posts: 96
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!
Reply With Quote
  #19 (permalink)  
Old 05-05-2006, 09:34 AM
Intermediate Member
 
Posts: 20
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.
Reply With Quote
  #20 (permalink)  
Old 05-07-2006, 07:35 PM
Loyal Member
 
Posts: 96
Default

Confirmed working with the change in the add_disclaimer file.

Thanks so much.

adrian
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.