Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mimedefang Adding Footer

Posted on 2006-11-02
10
Medium Priority
?
801 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
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…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…

721 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