[Mimedefang] disclamer only for out going mails.

Gary Funck gary at intrepid.com
Fri Dec 16 14:46:35 EST 2005


> From: bablu bablu
> Sent: Friday, December 16, 2005 2:32 AM
>
> I am just making a genuine effort to get some help.

Apart from the fact that there are no great supporters on this
list of adding disclaimers, it is also true that there is
no direct implementation in the mimedefang filter
as it comes out of the box.

You mentioned "I am not much of script writer....".  Unfortunately,
that's a bit of problem if you're working with MIMEDefang -- it is
set up to let you "roll your own" mail filters, and that requires
some proficiency in Perl.  Remember, that when you work on a MIMEDefang
filter, you're possibly working with a company's mail system at a
important level.  It is oh-so-easy to drop mail, send back unwarranted
bounces, and so on.  In short, MdF may not be the tool of choice for
you, if you can't bridge the gap to working with Perl scripts.  Even if
someone gave you a template for how to add disclaimers, you'll still
need to change/add some code to detect whether a message is outgoing
or not, and you'll need to add your own disclaimer text, which may require
some knowledge of Perl's quoting rules, or how to write a Perl code
sequence that reads the disclaimer text in from a file.

Personally, I think it would be good if a page/two were added to the Wiki
that demonstrates a working implementation of how to add a boilerplate
to outgoing mail.  The question comes up a lot, and even though the
idea of adding disclaimers demonstrates a certain degree of Corporate
Cluelessness, http://goldmark.org/jeff/stupid-disclaimers/
it is an often-requested feature.

As I mentioned in my previous e-mail, first you'll have to determine
whether the mail is outgoing or not,
http://tinyurl.com/e4lx6
That particular piece of code disables all MIMEDefang processing of
all outgoing mails, which is _not_ what you want.  However, it shows
you how to check for outgoing mail.  You'll need that code sequence
in your boilerplate adding code (see below), but you'll be adding it to
filter_end().  You'll need to capture the Sender's IP address in
filter_sender().  As I understand things, filter_sender() can only
communicate with filter_end() via a file in the $CWD directory (or via
an external database, which is more complicated).

Next, spend some time with "man mimedefang-filter", note the following:

       append_text_boilerplate($entity, $boilerplate, $all)
              This action  should  only  be  called  from  filter_end.   It
              appends  the  text "\n$boilerplate\n" to the first text/plain
              part (if $all is 0) or to all text/plain parts  (if  $all  is
              1).

       append_html_boilerplate($entity, $boilerplate, $all)
              This  action  should only be called from filter_end.  It adds
              the text "\n$boilerplate\n" to the first text/html  part  (if
              $all  is  0)  or to all text/html parts (if $all is 1).  This
              function tries to be smart about inserting  the  boilerplate;
              it  uses  HTML::Parser to detect closing tags and inserts the
              boilerplate before the </body> tag if there is one, or before
              the  </html>  tag  if  there  is  no </body>.  If there is no
              </body> or </html> tag, it appends the boilerplate to the end
              of the part.

              Do  not use append_html_boilerplate unless you have installed
              the HTML::Parser Perl module.

and then turn to the MIMEDefang How-To:
http://www.mickeyhill.com/mimedefang-howto/#s9
Scan down the page, to section 9.8 ("filter_end"), and note this part,

Another common use of filter_end is the insertion of boilerplate text into a
message. The append_text_boilerplate and append_html_boilerplate functions
append text to the first text/plain or text/html part found in the message.
These functions would be added inside the existing filter_end:

append_text_boilerplate($entity, "All information contained in " .
    "this email is confidential and may be used by the intended " .
    "recipient only.", 0);

append_html_boilerplate($entity, "All information contained in " .
    "this email is confidential and may be used by the intended " .
    "recipient only.", 0);

Your boilerplate adding code will need to be added to filter_end,
as described.

Others here, please correct me if the following is incorrect,
or if there is an easier way, but here are the steps that based
upon my understanding need to be done to accomplish the task:

1. assert MX_SENDER_CHECK in /etc/sysconfig/mimedefang:

MX_SENDER_CHECK=yes

2. add checking code in fllter_sender() to write the sender's
IP address and e-mail address to a file called sender_id.txt
under the $CWD directory.

3. in filter_end() read the Sender's IP address from the
sender_id.txt file and check it against the IP addresses
of your local machines, using the technique mentioned
earlier.  If it is determined to be outgoing, then add
the boilerplate.

4. Restart MimeDefang and test.  It would be best to
test this on a test server, or perhaps others here could
suggest a way to fire up another copy of sendmail (and
MimeDefang), working off another SMTP port so that the
code can be properly tested before deploying it?  I'd
guess that some customization of startup scripts would
be required.  In my view, a separate test server would
be the most straightforward way to go.

If I have the time, I'll try and write the code, but
would appreciate hearing from others more experienced
in modifying MdF before implementing the suggested
approach.




More information about the MIMEDefang mailing list