Rewriting mail subject with Formail
Hi Guys,
I've done a little script that redirects all PHP mails to a single mailbox from the development server using formail and sendmail. The script is like this: Code:
#!/bin/bash Code:
> echo "test mail" | ./mrewrite my@address.com - It redirects all emails to single mailbox - It even inserts X-original-to,bcc,cc headers to know the intended recipient of the mails However, now developers are asking that it would be so good if on top of this I were to attach the original recipients (cc and bcc included) into the subject of the mails, like so: Code:
Subject: (to: originalto@foo.bar, original2to@foo.bar, cc: originalcc, bcc: originalbcc) --- Original Subject of the Mail |
AFAIK, it's just the -A switch to append. You're already using it for the TO field, so I'm not sure why that didn't occurr to you.. maybe I'm misunderstanding what it does.
|
Quote:
Like: -A "Subject: $to, $cc ..." or -A cc." - ".to." - ...", or how? The point is that I need to include the original recipients in the subject line, not just the header (that's working already). Ok I'm obviously using this tool for the first time so I maybe missing some very trivial thing. But still... |
This is how I think it might be done (untested):
formail -A "Subject: (to: $(formail -x To: <filename>))" That only uses the To field to keep the example simple. I'm guessing that both instances of formail can't use stdin. I'm uncertain, but <filename> could perhaps be /dev/stdin if you want to try it. Also, I used $(formail...) for command substitution. Alternatively, ticks would work too: eg. `formail...` |
All times are GMT -5. The time now is 07:13 PM. |