Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mimedefang Adding Footer

Posted on 2006-11-02
10
Medium Priority
?
816 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
ID: 17859336
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
ID: 17859393
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 17864835
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:PsiCop
ID: 17866963
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
 
LVL 1

Author Comment

by:Terry Rogers
ID: 17936619
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
ID: 17965772
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
ID: 17966010
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
ID: 17986761
*shrug* Whatever.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17987473
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…

926 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