LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-21-2006, 06:18 AM   #1
SlackDaemon
Member
 
Registered: Mar 2006
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222

Rep: Reputation: 30
Filtering outgoing mail through Procmail


Hi,

I am writing an application that needs its outgoing mail processed from a sendmail server. More specifically the application needs its outgoing mail checked for a particular keyword in the Subject line. If the keyword matches, the email will be forwarded to a particular group of users.

The incoming message processing was very simple to implement through ~/.procmailrc, but I am struggling with the outgoing part. From what I've gathered I have to add some additional configurations in /etc/mail/sendmail.mc.

I am not familiar with m4 but the configurations start with:
LOCAL_RULESETS
LOCAL_RULE_0

If someone could provide me with the proper configurations or another means of achieving the same end I'd be really grateful.

cheers!
 
Old 06-21-2006, 08:21 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,539
Blog Entries: 51

Rep: Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604Reputation: 2604
If the keyword matches, the email will be forwarded to a particular group of users.
Why not have mail sent to a distribution alias instead of trying to compensate for what looks like a deficiency in the application forcing a kludge on Sendmail? As far as I know by default outbound email doesn't flow through procmail. If you want to take that route you might want to look for clues at methods / subjects about scanning outbound email (using a SMTP proxy on another port forwarding to the "real" MTA) or those about people needing to tack those ghastly "legal" footers onto outbound email (which nearly always point to using a custom milter).
 
Old 06-22-2006, 07:05 AM   #3
SlackDaemon
Member
 
Registered: Mar 2006
Distribution: RedHat, Slackware, Experimenting with FreeBSD
Posts: 222

Original Poster
Rep: Reputation: 30
Thanks

your suggestion regarding the SMTP proxy worked. I used proxysmtp-1.2.1 to implement outgoing and incoming mail filtering. The trick is to switch around the ports. The proxy is set to listen on port 25 whereas the actual MTA is listening on another port. This way the proxy will be able to filter both incoming and outgoing mail. Once the proxy is finished processing the message it is simply forwarded to the actual MTA.

The problem was that I couldn't simply generate a copy of the message with the 'mail' utility as this would cause an infinite loop to occur. Instead the filtering script had to insert the message into the target user's spool file directly.

echo "From username@domain `date`" >> /var/spool/mail/targetuser
echo "Return-Path: <username@domain>" >> /var/spool/mail/targetuser
cat tmpmessage_file >> /var/spool/mail/targetuser

well thats the short of it anyway. Perhaps not the most elegant solution but it works

The problem could have been handled better within the application itself. However, I am building around legacy modules (no source code available) which only allows one email to be specified in it's configuration files, hence the need for outgoing mail filtering.

Regards
 
  


Reply

Tags
filtering, mail, outgoing


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Procmail Filtering Using a Full Subject Line lmcilwain Linux - Software 3 02-08-2006 01:07 PM
Filtering Outgoing Mail With Sendmail WeNdeL Linux - Software 1 08-25-2004 03:12 PM
Procmail not filtering WiWa Linux - Networking 0 07-06-2004 02:22 PM
Procmail not filtering tomac Linux - General 0 05-26-2004 03:15 PM
Procmail or other filter for outgoing mail gabriele_101 Linux - Software 3 08-18-2003 05:35 PM


All times are GMT -5. The time now is 10:42 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration