0

How do I inject the sender's address, or any other header, into the message body using procmail? I've already found how to inject a static string into the message body, which works fine:

:0bfw 
| echo "I have inserted this line into the message." ; echo "" ; ca

So, instead of injecting that static string into the message, how do I inject the sender's address?

ricksebak
  • 101
  • 1
  • 6

1 Answers1

1

Set the variables, then echo them into the message body, like this:

SUBJECT_=`formail -XSubject:`
FROM_=`formail -XFrom:`
TO_=`formail -XTo:`
CC_=`formail -XCc:`


:0bfw 
| echo "${SUBJECT_}" ; echo "${FROM_}" ; echo "${TO_}" ; echo "${CC_}" ; echo "" ; cat
ricksebak
  • 101
  • 1
  • 6
  • 1
    If you want the sender's email terminus and nothing else (i.e. just `parsley@graceland.example.net` pro `Elvis (the King) Parsley `), remember also the slightly tricky `formail -rtzxTo:` which generates a reply message's headers, then extracts the `To:` address from them. (The `-t` option creates a preference for e.g. the `Reply-To:` address which may or may not be what you want. Both `-r` and `-rt` are decidedly more complex than just extracting the value of `From:`.) – tripleee Nov 19 '14 at 06:39