Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

content filter - Altermime

119 views
Skip to first unread message

Meijer, Harm

unread,
Jun 28, 2007, 6:56:13 AM6/28/07
to
Hi all,

I am trying to add a disclaimer to all outgoing e-mail by the use of
altermime. I have followed all of the instructions on:
http://www.paw.za.org/docs/howtos/postfix-altermime/postfix-altermime-ho
wto.html#toc2

But still no disclaimer is added to my outgoing e-mail. I have set up a
test
server to try all of this out. The part of the configuration that
matters (I suppose) looks like this:

# ======================= master.cf
========================================
127.0.0.1:smtp inet n - n - - smtpd
-o content_filter=disclaimer
192.168.1.13:smtp inet n - n - -
smtpd
-o content_filter=disclaimer
192.168.1.253:smtp inet n - n - -
smtpd
-o content_filter=disclaimer
172.27.77.114:smtp inet n - n - -
smtpd
-o content_filter=disclaimer

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

#
========================================================================
==

Even though I added all of the available interfaces and there are no
other transport means defined (I wonder does local delivery bypass all
of these) it still does not make the addition of the disclaimer.

Any suggestions would be greatly appreciated.

Best regards,

Harm Meijer

Ralf Hildebrandt

unread,
Jun 28, 2007, 7:21:49 AM6/28/07
to
* Meijer, Harm <Harm....@itsmaxeda.com>:

> Hi all,
>
> I am trying to add a disclaimer to all outgoing e-mail by the use of
> altermime. I have followed all of the instructions on:
> http://www.paw.za.org/docs/howtos/postfix-altermime/postfix-altermime-howto.html#toc2
>
> But still no disclaimer is added to my outgoing e-mail. I have set up a
> test
> server to try all of this out. The part of the configuration that
> matters (I suppose) looks like this:
How do you inject them mail?


> 127.0.0.1:smtp inet n - n - - smtpd -o content_filter=disclaimer

Only mail injected using SMTP on 127.0.0.1, 192.168.1.13,
192.168.1.253 and 172.27.77.114, port 25 gets "treated"

I hope you're not using sendmail to test...

--
Ralf Hildebrandt (Ralf.Hil...@charite.de) pl...@charite.de
Postfix - Einrichtung, Betrieb und Wartung Tel. +49 (0)30-450 570-155
http://www.arschkrebs.de
The only secure Microsoft software is what's still shrink-wrapped in the
warehouse.

Meijer, Harm

unread,
Jun 28, 2007, 7:34:20 AM6/28/07
to
Hi Ralf and all,

Thanks for you quick response...

And errhrh I am sorry to say I was using sendmail to test (is there
anyway of making that work too?). Anyway so after your response I did a
telnet on the box connection to port 25 and send myself an e-mail and it
did include the disclaimer this time (great thanks for that).

Now another quick question... I am sorry if it is a bit foolish.

How would I go about adding different disclaimers per outgoing e-mail
depending on the senders domain?

Best regards,

Harm Meijer

-----Oorspronkelijk bericht-----
Van: owner-pos...@postfix.org
[mailto:owner-pos...@postfix.org] Namens Ralf Hildebrandt
Verzonden: donderdag 28 juni 2007 13:22
Aan: postfi...@postfix.org
Onderwerp: Re: content filter - Altermime

Ralf Hildebrandt

unread,
Jun 28, 2007, 8:00:43 AM6/28/07
to
* Meijer, Harm <Harm....@itsmaxeda.com>:

> Hi Ralf and all,
>
> Thanks for you quick response...
>
> And errhrh I am sorry to say I was using sendmail to test (is there
> anyway of making that work too?). Anyway so after your response I did a
> telnet on the box connection to port 25 and send myself an e-mail and it
> did include the disclaimer this time (great thanks for that).

Excellent.

> Now another quick question... I am sorry if it is a bit foolish.
>
> How would I go about adding different disclaimers per outgoing e-mail
> depending on the senders domain?

You'd need to pimp the script :)

> http://www.paw.za.org/docs/howtos/postfix-altermime/postfix-altermime-howto.html#toc2

This has a section with "Creating The Script To Run alterMIME". This
script needs some

if sender ~= "@fooo.com$"
then
...
fi
clauses.

BTW:

$SENDMAIL "$@" <in.$$

should be

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


--
Ralf Hildebrandt (Ralf.Hil...@charite.de) pl...@charite.de
Postfix - Einrichtung, Betrieb und Wartung Tel. +49 (0)30-450 570-155
http://www.arschkrebs.de

We can't prove that God exists. However, we can prove that if God does
exist, he's pretty good at math. In fact, we can prove that even if
God doesn't exist, he's still pretty good at math.

Meijer, Harm

unread,
Jun 28, 2007, 9:09:27 AM6/28/07
to
Hi Ralf and all,

Thanks agian very much appreciated.

As suggested I pimped the script here it is (just to share it ... and
maybe get some feedback if something seems like a bad idea)

================================================
#!/bin/sh
# Localize these.
set -x

while getopts f: sender
do
case ${sender} in
f) domain=$(echo ${OPTARG} | awk -F"@" '{ print $2 }');;
esac
done

case ${domain} in
*some.domain) disclaimer=/etc/postfix/disclaimers/some.domain.txt;;
*another.domain)
disclaimer=/etc/postfix/disclaimers/another.domain.txt;;
*) disclaimer=/etc/postfix/disclaimers/general.txt;;
esac

INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail

# 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; }

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

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

exit $?
==========================================================
Nothing to spectacular but it does the trick...

Thanks again and best regards,

Harm Meijer

-----Oorspronkelijk bericht-----
Van: owner-pos...@postfix.org
[mailto:owner-pos...@postfix.org] Namens Ralf Hildebrandt

Verzonden: donderdag 28 juni 2007 14:01


Aan: postfi...@postfix.org
Onderwerp: Re: content filter - Altermime

* Meijer, Harm <Harm....@itsmaxeda.com>:

Stefano Mason

unread,
Jun 28, 2007, 10:06:42 AM6/28/07
to
Meijer, Harm wrote:
> Hi Ralf and all,
>
> Thanks agian very much appreciated.
>
> As suggested I pimped the script here it is (just to share it ... and
> maybe get some feedback if something seems like a bad idea)
>
Dear all,
another solution:

Pros:
- If you make a mistake this is isolated...
- A very small shell script run fast than...

Cons:
- Setup a little more complicated

###

master.cf

# disclaimer A
disA unix - n n - - pipe
flags=Rq user=filter argv=/etc/postfix/disclaimerA -f ${sender} --
${recipient}

# disclaimer B
disB unix - n n - - pipe
flags=Rq user=filter argv=/etc/postfix/disclaimerB -f ${sender} --
${recipient}


Pay attention for next step (sorry if I don't supply an example. Your
landscape is the driver):
Use a

check_sender_access hash:/etc/postfix/maps/access_sender

positioned in the right place for your landscape.

/etc/postfix/maps/access_sender:

he...@domainA.it FILTER disA:
domainA.it FILTER disB:

Best regards.
Stefano

Jairsinho Ramirez Ruiz

unread,
Jul 17, 2007, 4:32:38 PM7/17/07
to
Is there any way to add the disclaimer only for ALL extenal domains (internet)
and not for internal ones, using altermime?

We don't want to add the disclaimer when massages are sent between our
internal users.

Thank you.
Saludos.

== postconf -n ==== from my server

alias_database = hash:/etc/postfix/aliases
alias_maps = hash:/etc/postfix/aliases
bounce_queue_lifetime = 1d
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
default_database_type = hash
default_process_limit = 1024
html_directory = no
mail_owner = postfix
mailbox_size_limit = 0
mailq_path = /usr/bin/mailq
manpage_directory = /usr/man
maximal_queue_lifetime = 1d
message_size_limit = 0
mydomain = domain.com.mx
myhostname = smtpgw01.$mydomain
mynetworks = /etc/postfix/trusted
newaliases_path = /usr/sbin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/lib/sendmail
setgid_group = postdrop
smtp_connection_cache_on_demand = yes
smtp_connection_cache_time_limit = 5s
smtp_data_done_timeout = 3600s
smtpd_banner = $myhostname Microsoft ESMTP MAIL Service, Version: 6.0.3790.2825
smtpd_recipient_restrictions = permit_mynetworks,
reject_unauth_destination
transport_maps = hash:/etc/postfix/transport

ni...@javacat.f2s.com

unread,
Jul 18, 2007, 4:24:05 AM7/18/07
to
Quoting Jairsinho Ramirez Ruiz <jair....@gmail.com>:

> Is there any way to add the disclaimer only for ALL extenal domains (internet)
> and not for internal ones, using altermime?
>
> We don't want to add the disclaimer when massages are sent between our
> internal users.

I use the following as my filter script. You could change the commented out if statement to whatever suits your org.

#!/bin/bash
ALTERMIME=/usr/local/bin/altermime
ALTERMIME_DIR=/var/spool/altermime
SENDMAIL=/usr/sbin/sendmail.postfix

TEMPFAIL=75
UNAVAILABLE=69

#RECIP=`echo $* | awk '{print $NF}'| tr [A-Z] [a-z]`

## THESE VARS COULD BE USEFUL IF WE HAVE TO GET FANCIER ##
# SENDER=`echo $* | awk '{print $2}'| tr [A-Z] [a-z]`
# RECIP_DOMAIN=`echo $RECIP | awk -F"@" '{print $2}'`
# SEND_DOMAIN=`echo $SENDER | awk -F"@" '{print $2}'`

echo "RECIP: $RECIP SENDER: $SENDER RECIPIENT DOMAIN: $RECIP_DOMAIN SENDER DOMAIN: $SEND_DOMAIN" >> /tmp/ARGS

cd $ALTERMIME_DIR || { echo $ALTERMIME_DIR does not exist; exit $TEMPFAIL; }

trap "rm -f in.$$" 0 1 2 3 15

#if [ $RECIP_DOMAIN == $SEND_DOMAIN ]; then
# DISCLAIMER=/etc/postfix/filter/empty_disclaimer.txt
#else
# DISCLAIMER=/etc/postfix/filter/disclaimer.txt
#fi

DISCLAIMER=/etc/postfix/filter/disclaimer.txt

cat >in.$$ || { echo "Cannot write to `pwd`"; exit $TEMPFAIL; }

$ALTERMIME --input=in.$$ \
--disclaimer=$DISCLAIMER \
--disclaimer-html=/etc/postfix/filter/disclaimer.txt || { echo Message content rejected; exit $UNAVAILABLE; }

Adam Dempsey

unread,
Jul 18, 2007, 9:24:36 AM7/18/07
to
How would I make it always add the disclaimer, except when it matches
domain.com and in that case it shouldn't add anything?


On 28 Jun, 15:06, Stefano Mason <stefano.ma...@t-systems.it> wrote:
> Meijer, Harm wrote:
> > Hi Ralf and all,
>
> > Thanks agian very much appreciated.
>
> > As suggested I pimped the script here it is (just to share it ... and
> > maybe get some feedback if something seems like a bad idea)
>
> Dear all,
> another solution:
>
> Pros:
> - If you make a mistake this is isolated...
> - A very small shell script run fast than...
>
> Cons:
> - Setup a little more complicated
>
> ###
>
> master.cf
>
> # disclaimer A
> disA unix - n n - - pipe

> flags=Rq user=filterargv=/etc/postfix/disclaimerA -f ${sender} --


> ${recipient}
>
> # disclaimer B
> disB unix - n n - - pipe

> flags=Rq user=filterargv=/etc/postfix/disclaimerB -f ${sender} --

Jairsinho Ramirez Ruiz

unread,
Jul 18, 2007, 12:27:07 PM7/18/07
to
Thank you nick, it is pretty much what I need.

Saludos.

0 new messages