Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th June 2008, 15:58
Challenger Challenger is offline
Junior Member
 
Join Date: Apr 2008
Posts: 19
Thanks: 5
Thanked 1 Time in 1 Post
Default Email editing with Procmail, sed etc

Hi Everyone,

I am trying to use Procmail (with subsequent tools like sed) to amend an incoming email, but I'm still not having much luck even after reading a thousand FAQs! Could somebody please help?

What I am trying to do is this:

1. Deliver an email as normal, BUT
2. Amend and forward a copy of that amended email to another email address. The amendments should be:
a. Insert as first line of text 'Email from John'
b. Send only 160 characters of the message.
3. The added complication is that the message may, or may not, be in MIME (HTML) format, so the 160 characters need to be (I guess) extracted from the plain text part only...

I know this is asking a lot, but could anyone please help?

Andy
Reply With Quote
Sponsored Links
  #2  
Old 9th June 2008, 01:04
Challenger Challenger is offline
Junior Member
 
Join Date: Apr 2008
Posts: 19
Thanks: 5
Thanked 1 Time in 1 Post
 
Default

I have solved this one, but in case it helps others my solution was as follows:

1. Procmail-lib contains a fantastic script called pm-jamime-kill.rc, which does most of the hard work for you. Ensure that you have procmail-lib installed of course; it is in most of the common Linux repositories.

2. Once that is installed, add the variable declaration PMSRC='your procmail-lib directory' near the start of procmailrc. This is important - don't simply amend the path for the calling script because that in turn calls other scripts in procmail-lib.

3. Then simply add something like the following into the body of procmailrc:

:0c
* ^From.*some_email_address # Rem to delimit the @ with a \
{
:0
* ^X-Mailer:.*(Microsoft.*Express|Mozilla|Office|AOL)
{ JA_MIME_TYPE = "text/html" }
INCLUDERC=$PMSRC/pm-jamime-kill.rc
:0 fhw
| cat - ; echo "Email from Whoever: "
:0
! forwarding_email_address
}

That's it. I hope it works for you.

Andy
Reply With Quote
The Following User Says Thank You to Challenger For This Useful Post:
falko (9th June 2008)
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hotmail rejects outgoing email nzimas Server Operation 3 1st May 2009 03:39
CacheALL email problem no.2 Snowman General 2 2nd August 2007 09:45
email forwarding locally consumes all resources rdells General 20 1st May 2006 19:43
plenty of procmail/trashscan processes ZyanKLee Installation/Configuration 10 27th December 2005 20:09
procmail <defunct> ZyanKLee Installation/Configuration 1 19th December 2005 00:58


All times are GMT +2. The time now is 20:55.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.