procmail
[Top] [All Lists]

Re: [pro] Adding to the start of the message body

2010-03-16 16:27:16

This is what I call a 'stupid pet trick'. I actually did this by accident recently. If you write a blank line to the end of the header, followed by a text line, most e-mail clients will treat that extra line as the first line of a text-only body.

As you have noticed, it "breaks" when you try to use it on 'multipart' messages - with HTML or attached files....

If it does not interfere with some other design goal, you may want to consider using:

:0 fwh
^Subject: \/.*
| formail -I"Subject: [FORWARDED] $MATCH"

This will add the comment [FORWARDED] to the Subject line, but leave
the body structure alone.

- Charles


On Tue, 16 Mar 2010, sreti(_at_)bidmc(_dot_)harvard(_dot_)edu wrote:
Hi,
I have code that places a message at the beginning of the body of an email
and it works. It is modified from an online tip, but I really want to
understand how it works so I can be better informed for similar coding.

Below is the online tip credited to Phillip Guenther – thanks. Mycode
effectively mimics this, and the log follows.

My interpretation is this:
fhw = pipe the header
Concantenate with cat onto the end of the header. I think that is what the
cat – does
Write the message with echo
Email the message

Basically then it adds to the end of the header and therefore pretends to be
the beginning of the body.

I have also observed that it only works on emails with HTML off, which is a
bit of a bother.

Am grateful for further explanations and thanks again to the person who
placed it online initially, very helpful.

Shane

ONLINE TIP
I have a really simple procmail question. All I want to do is add a line
"======= Forwarded Mail =========="
to the top of the body of all incoming messages, and forward them to another
account.

Let start by considering the first part of the question only. This is how it
is done. The solution owes heavily to Philip Guenther.
:0
{
  :0 fhw
  | cat - ; \
  echo "===== Filtered email ====="
  :0:
 ${DEFAULT}
}


MYCODE
#ADD TO TOP OF BODY
:0
*^To:.*Emailbodyadd
{
:0fhw
| cat - ; echo "This is entered by Me"
 
:0
!sreti(_at_)bidmc(_dot_)harvard(_dot_)ed
}
 

LOG
procmail: Match on "^To:.*Emailbodyadd"
procmail: Executing " cat - ; echo "This is entered by Shane""
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi
sreti(_at_)bidmc(_dot_)harvard(_dot_)ed"
procmail: Executing 
"/usr/sbin/sendmail,-oi,sreti(_at_)bidmc(_dot_)harvard(_dot_)ed"
procmail: Notified comsat: "reti@:/usr/sbin/sendmail -oi
sreti(_at_)bidmc(_dot_)harvard(_dot_)ed"
>From sreti(_at_)bidmc(_dot_)harvard(_dot_)edu  Tue Mar 16 08:38:36 2010
 Subject: Body add test
  Folder: /usr/sbin/sendmail -oi sreti(_at_)bidmc(_dot_)harvard(_dot_)ed 
                1337
 



 
Shane Reti (QSM), M.D.
Director, International Programs,
Project Manager, Division Facilities,
Division of Clinical Informatics,
Beth Israel Deaconess Medical Center,
330 Brookline Ave,
Boston, MA 02215
Tel:  617-667-1516
Cell: 857-445-5615
Fax: 617-667-1518





____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail
<Prev in Thread] Current Thread [Next in Thread>