[Mimedefang] Mail Restrictions with sendmail and mimedefang

Indunil Jayasooriya indunil75 at gmail.com
Fri Sep 7 05:07:43 EDT 2007


This is extremely basic and is covered in the mimedefang-filter
 man page.  Basically, you have to define what "outgoing emails" means
 (in sendmail's view of the world, mail comes in, gets processed, and
 goes out again).  Then in filter_end() you do something like

 if ($outgoing) {
   add_recipient(" mailoutgoing at example.com");
 }

 $outgoing is a variable that you set according to whether it is
 "outgoing emails".


 HEY, Thanks for your request.

 I am not good in perl. So difficult to understand codes.

 Anyway, I added  below code  to  filter_end section @
/etc/mail/mimedefang-filter  for outgoing mails.  But still no luck.

this is  the code.


 if ($outgoing eq "@example.com") {
 add_recipient("mailoutgoing at example.com");
 }

 What I need is , Whenever user sends emails (their email addresse
will be  userx at example.com , usery at example.com and so on), email
address mailoutgoing at example.com should receive them.


 Where have I gone wrong?

 Can you rectify my code?

 If you need more ?  pls find the whole section of filter_end in
/etc/mail/mimedefang-filter

And pay attention to the code written near the Bottom.

 # If SpamAssassin found SPAM, append report.  We do it as a separate
 # attachment of type text/plain
 sub filter_end {
    my($entity) = @_;

   # If you want quarantine reports, uncomment next line
    # send_quarantine_notifications();

     # IMPORTANT NOTE:  YOU MUST CALL send_quarantine_notifications() AFTER
    # ANY PARTS HAVE BEEN QUARANTINED.  SO IF YOU MODIFY THIS FILTER TO
     # QUARANTINE SPAM, REWORK THE LOGIC TO CALL send_quarantine_notifications()
     # AT THE END!!!

     # No sense doing any extra work
     return if message_rejected();

     # Spam checks if SpamAssassin is installed
     if ($Features{"SpamAssassin"}) {
         if (-s "./INPUTMSG" < 100*1024) {
             # Only scan messages smaller than 100kB.  Larger messages
             # are extremely unlikely to be spam, and SpamAssassin is
             # dreadfully slow on very large messages.
             my($hits, $req, $names, $report) = spam_assassin_check();
             my($score);
             if ($hits < 40) {
                 $score = "*" x int($hits);
             } else {
                 $score = "*" x 40;
             }
             # We add a header which looks like this:
             # X-Spam-Score: 6.8 (******) NAME_OF_TEST,NAME_OF_TEST
             # The number of asterisks in parens is the integer part
             # of the spam score clamped to a maximum of 40.
             # MUA filters can easily be written to trigger on a
             # minimum number of asterisks...
             if ($hits >= $req) {
                 action_change_header("X-Spam-Score", "$hits ($score) $names");
                 md_graphdefang_log('spam', $hits, $RelayAddr);

                 # If you find the SA report useful, add it, I guess...
                 action_add_part($entity, "text/plain", "-suggest",
                                "$report\n",
                                 "SpamAssassinReport.txt", "inline");
             } else {
                 # Delete any existing X-Spam-Score header?
                 action_delete_header("X-Spam-Score");
             }
         }
     }

     # I HATE HTML MAIL!  If there's a multipart/alternative with both
     # text/plain and text/html parts, nuke the text/html.  Thanks for
     # wasting our disk space and bandwidth...

     # If you want to strip out HTML parts if there is a corresponding
     # plain-text part, uncomment the next line.
     # remove_redundant_html_parts($entity);

     md_graphdefang_log('mail_in');

     # Deal with malformed MIME.
     # Some viruses produce malformed MIME messages that are misinterpreted
     # by mail clients.  They also might slip under the radar of MIMEDefang.
    # If you are worried about this, you should canonicalize all
     # e-mail by uncommenting the action_rebuild() line.  This will
     # force _all_ messages to be reconstructed as valid MIME.  It will
     # increase the load on your server, and might break messages produced
     # by marginal software.  Your call.

     # action_rebuild();
 }


 if ($outgoing eq "@example.com") {
   add_recipient("mailoutgoing at example.com");
 }


 # DO NOT delete the next line, or Perl will complain.
 1;




-- 
Thank you
Indunil Jayasooriya



More information about the MIMEDefang mailing list