We have already dicussed how to install and configure postfix now we will learn about How to add a Disclaimer To Outgoing Emails in Postfix using altermime.

alterMIME is a small program which is used to alter your mime-encoded mailpacks as typically received by Inflex, Xamime and AMaViS.

What can alterMIME do?

Insert disclaimers
Insert arbitary X-headers
Modify existing headers
Remove attachments based on filename or content-type
Replace attachments based on filename

Installing alterMIME in debian

Use the following command to install altermime

#aptitude install altermime

This will complete the installation.

Configure altermime

Next we need to create the user filter with the home directory /var/spool/filter filter - alterMIME will be run as that user

#useradd -r -c “Postfix Filters” -d /var/spool/filter filter

#mkdir /var/spool/filter

#chown filter:filter /var/spool/filter

#chmod 750 /var/spool/filter

Afterwards we create the script /etc/postfix/disclaimer which executes alterMIME. Debian’s alterMIME package comes with a sample script that we can simply copy to /etc/postfix/disclaimer

#cp /usr/share/doc/altermime/examples/postfix_filter.sh /etc/postfix/disclaimer

#chgrp filter /etc/postfix/disclaimer

#chmod 750 /etc/postfix/disclaimer

Now we need to add disclaimer to only outgoing email

we create the file /etc/postfix/disclaimer_emails which holds all sender email addresses (one per line) for which alterMIME should add a disclaimer

#vi /etc/postfix/disclaimer_emails

admin@domain.com
user1@domain.org

Save and exit the file

Now we open /etc/postfix/disclaimer and modify some configuration you can check this file

Next we need the text file /etc/postfix/disclaimer.txt which holds our disclaimer text. Debian’s alterMIME package comes with a sample text that we can use for now

#cp /usr/share/doc/altermime/examples/disclaimer.txt /etc/postfix/disclaimer.txt

Finally we have to tell Postfix that it should use the /etc/postfix/disclaimer script to add disclaimers to outgoing emails. Open /etc/postfix/master.cf and add -o content_filter=dfilt: to the smtp line:

#vi /etc/postfix/master.cf

# # Postfix master process configuration file. For details on the format # of the file, see the master(5) manual page (command: “man 5 master”). # # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ==========================================================================

smtp inet n - - - - smtpd

-o content_filter=dfilt: [...]
at the end of the file add the following lines

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

Save and exit the file.

Now you need to restart the postfix mail server using the following command

#/etc/init.d/postfix restart

Share

  5 Responses to “How to add a Disclaimer To Outgoing Emails in Postfix”

  1. Hi there,

    I set this up - but the HTML isn’t being parsed properly by Outlook 2007.

    It puts a few = signs into the body of the HTML disclaimer, it happens when it’s sent as plaintext and HTML.

    Any ideas? I can’t figure it out!

    Cheers,

    Andrew

  2. Help needed,
    I am using Fedora core 6 and I had tried to add disclamer as per the instructions in this page, also googled and tried lots of other ways too.

    But when ever I try to send mail and cheks the maillog, its showing this error, and the mail is not send at all
    I am pasting the error from /etc/log/maillog

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Oct 11 08:22:38 it001 pipe[5108]: fatal: pipe_command: execvp /etc/postfix/disclaimer: Permission denied
    Oct 11 08:22:38 it001 sendmail[5102]: m9BCMcLV005102: to=test@test.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30063, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 981A050068)
    Oct 11 08:22:38 it001 postfix/pipe[5107]: 981A050068: to=, relay=dfilt, delay=0.09, delays=0.06/0.01/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command output: pipe: fatal: pipe_command: execvp /etc/postfix/disclaimer: Permission denied )
    Oct 11 08:22:38 it001 postfix/smtpd[5103]: disconnect from it001[127.0.0.1]
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

  3. You should add

    #groupadd filter

    just below

    #useradd -r -c “Postfix Filters” -d /var/spool/filter filter

  4. Don´t work, using the sample.sh as disclaimer when the user send mail over imap (squierrelmail)

    $from_address = From:user@domain, when sendin in imap and don´t work,

    sendin in pop $from_address = user@domain and works fine

  5. i’m not find this line

    -o content_filter=dfilt: [...]
    at the end of the file add the following lines

    please tell me how

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2011 Debian Admin