Solved

Mimedefang Adding Footer

Posted on 2006-11-02
10
733 Views
Last Modified: 2013-12-17
I currently have the following setup in my mimedefang-filter file in /etc/mail ...

 # Add footer to outgoing emails
    if ($Sender =~ /contractpoint.co.uk/) {
        $text_footer = " ";
        $html_footer = " ";
    }

    if ($Sender =~ /tradeonlyplumbing.co.uk/) {
        $text_footer = " ";
        $html_footer = " ";
    }

    if ($Sender =~ /tradeonlyplumbing.com/) {
        $text_footer = " ";
        $html_footer = " ";
    }

    if ($Sender =~ /williams.uk.com/) {
        $text_footer = ".";
        $html_footer = "<b>.</b>";
    }

    append_text_boilerplate($entity,$text_footer,0);
    append_html_boilerplate($entity,$html_footer,0);

I need this to be modified so that any mail going from @williams.uk.com to @tradeonlypluming.com, @tradeonlypluming.co.uk or @williams.uk.com does not have the filter added. This also needs to be the case for @tradeonlyplumbing.com and @tradeonlyplumbing.co.uk.

I also need to specify some email address's that wont have a footer added, namely any outgoing mail from mickwilliams@williams.uk.com will not have a footer added.

I need to add the footer if any external address is in cc or bcc fields as well, but not if its sender is one of a set.

This is urgent and requires implementing ASAP.
0
Comment
Question by:Terry Rogers
  • 5
  • 3
10 Comments
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
Ugh.

Well, first, in your basic checking code, I wouldn't use $Sender, I'd use $RelayAddr. This is really more of a Perl programming issue. sendmail is only involved because MIMEDefang is a sendmail MILTER.

To check the TO:, CC: or BCC: fields, you're going to have to open and parse ./HEADERS - the MIMEDefang variables will only have the SMTP Envelope Headers, not the Message Headers.

Anyway, I'd have some list of your internal mail server IP addresses, perhaps in a hash:

%OurIPs = (   "10.1.2.3", 1, "192.168.11.11", 0 );

Where the Key is the IP address and the Value is a boolean indicator as to if E-Mail sent from that relay should get a footer.

Then, probably down in filter_end, you'd have code like this:

if ( exists($OurIPs{$RelayAddr}) )
   {
   # The sending host is one of our hosts, we need to think about footers
   if ( $OurIPs{$RelayAddr} )
       {
        # The boolean flag indicates the sending host is eligible to have
        #   footers appended
        ....
        parse ./HEADERS and add footers as appropriate
        ....
        }
     else
       {
        # This particular internal host is exempt from having footers appended
       }
else
    {
    # This isn't even our host
    # Run E-Mail thru SpamAssassin instead
    }

Again, this is more a Perl programming issue, and might be better-placed in the Perl TA.
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
0
 
LVL 1

Author Comment

by:Terry Rogers
Comment Utility
The problem with that solution is that not all hosts are internal, so are not coming from specified relay address's, we use authentication on the sending side outside of our network.

Im not a perl programmer and someone else made up the code ive posted here. Any more ideas?
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
I don't understand how the solution I proposed won't work. So you strip out the check for whether or not the host is internal - big deal. The general approach is still the same - somewhere down in filter_end, you need to open and examine the ./HEADERS file (where MIMEDefang stores the Message Headers), parse out the "To:", "CC:" and "BCC:" lines, and apply your business logic to the decision to add the footer.

As I said above, this is really a Perl programming issue (how to write the code) as opposed to a sendmail or OS issue. I really think you should take it over to the Perl TA, and in your Question, you need to include (or link to) the appropriate bits of MIMEDefang documentation.

You might also try the MIMEDefang website --> http://www.mimedefang.org

They have a Wiki with code examples, and also a mailing list where this would be a good question.

I've written my own MIMEDefang filter, but mine is geared towards anti-SPAM, and doesn't really get into the type of Message Header examination you need. But MIMEDefang is the correct tool for the job.
0
Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

 
LVL 1

Author Comment

by:Terry Rogers
Comment Utility
Issue resolved with the following code ...

    my $text_footer;
    my $html_footer;

    # Add footer to outgoing emails
    if ($Sender =~ /contractpoint.co.uk/) {
        $text_footer = "";
        $html_footer = "";
    }

    if ($Sender =~ /tradeonlyplumbing.co.uk/) {
        $text_footer = "";
        $html_footer = "";
    }

    if ($Sender =~ /tradeonlyplumbing.com/) {
        $text_footer = "";
        $html_footer = "";
    }

    if ($Sender =~ /williams.uk.com/) {
        $text_footer = "";
        $html_footer = "";
    }

    if ($Sender =~ /mickwilliams/) {
        $text_footer = "";
        $html_footer = "";
    }

    if ($Sender =~ /raystafford/) {
        $text_footer = "";
        $html_footer = "";
    }

    # Do a final check and if ALL the addresses are internal, clear the headers

    my $one_external = 0;

    foreach $recip (@Recipients) {
        if ( !(($recip =~ /tradeonlyplumbing/) or ($recip =~ /williams.uk.com/) or ($recip =~ /contractpoint.co.uk/)) ) {
                $one_external = 1;
        }
    }

    if ( $one_external == 0 ) {
        $text_footer = "";
        $html_footer = "";
    }

    # We have to look at adding footers to *ALL* mails as we don't know if an 'internal' mail is
    # coming from an internal relay or interface.

    if ( $text_footer ne "" ) {
        append_text_boilerplate($entity,$text_footer,0);
    }

    if ( $html_footer ne "" ) {
        append_html_boilerplate($entity,$html_footer,0);
    }
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
Considering the Asker posted to the MIMEDefang mailing list as I suggested in one of my Comments, I don't see that a refund of points is appropriate.
0
 
LVL 1

Author Comment

by:Terry Rogers
Comment Utility
No solution was provided, and the MIMEDefang mailing list also did not come up with anything, I had an external support company come up with the above solution.
0
 
LVL 34

Expert Comment

by:PsiCop
Comment Utility
*shrug* Whatever.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
Comment Utility
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

Wish Marketing would stop bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

Microsoft has released various new features which are capable of handling various tasks. One of these tasks is ‘Migration from pop3 to Exchange Server’. Pop3 data stores various data along mailboxes like contacts, tasks, etc. So, it becomes the need…
Utilizing an array to gracefully append to a list of EmailAddresses
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now