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.
Thread Tools Display Modes
Old 6th June 2008, 16: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?

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

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:

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

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

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


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 04:39
CacheALL email problem no.2 Snowman General 2 2nd August 2007 10:45
email forwarding locally consumes all resources rdells General 20 1st May 2006 20:43
plenty of procmail/trashscan processes ZyanKLee Installation/Configuration 10 27th December 2005 21:09
procmail <defunct> ZyanKLee Installation/Configuration 1 19th December 2005 01:58

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

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