Discussion:
save only mail body into a file
Zhiliang Hu
2017-11-10 14:52:31 UTC
Permalink
For one of my specific purposes I used to pass certain mails to a perl
script in order to save/process ONLY the mail body.

It can simplify the process if I can directly drop a mail body into a
file. I tried ':0 b' to save mailbody, 'formail -I' to remove mail
headers, without success. I also fail to find useful hints by onine
searches. Any advice/hint? :)

Thanks,
Zhiliang
Erik Christiansen
2017-11-11 05:40:30 UTC
Permalink
Post by Zhiliang Hu
For one of my specific purposes I used to pass certain mails to a perl
script in order to save/process ONLY the mail body.
It can simplify the process if I can directly drop a mail body into a file.
I tried ':0 b' to save mailbody,
That works for me:

:0b:
* ^Subject: *furdlesnurk
/tmp/snurdlefurk

***@ratatosk:~$ mail erik
Subject: furdlesnurk
Only the body should be saved to file.
Cc:

***@ratatosk:~$ cat /tmp/snurdlefurk
Only the body should be saved to file.
Post by Zhiliang Hu
'formail -I' to remove mail headers,
without success. I also fail to find useful hints by onine searches. Any
advice/hint? :)
More coffee. That sometimes helps. ;-)

Erik
Erik Christiansen
2017-11-11 05:57:00 UTC
Permalink
Post by Erik Christiansen
Post by Zhiliang Hu
'formail -I' to remove mail headers,
without success. I also fail to find useful hints by onine searches. Any
advice/hint? :)
More coffee. That sometimes helps. ;-)
OK, that part was a bit facetious. Have a look at the procmailex
manpage, and search for "lpr". There are several examples of body-only
processing, with and without conditionality.

Erik
(I still think coffee, and a Tim Tam, help when things go awry.)
Stan Ryckman
2017-11-11 08:26:53 UTC
Permalink
Post by Zhiliang Hu
For one of my specific purposes I used to pass certain mails to a perl
script in order to save/process ONLY the mail body.
It can simplify the process if I can directly drop a mail body into a
file. I tried ':0 b' to save mailbody, 'formail -I' to remove mail
headers, without success. I also fail to find useful hints by onine
searches. Any advice/hint? :)
:0 b works for me as it does for Erik Christiansen.

I will add, though, that if you must use external processing, something
more lightweight than perl would probably be a good idea.
In this case, you might use awk:
...
| awk 'NF==0{x=1;next}x' >> file

but of course, :0 b is preferable. I suspect you have some other typo
since you didn't provide context.

Coffee for me too, please.

Stan

Loading...