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
/usr/bin/formail -R to X-original-to -R cc X-original-cc -R bcc X-original-bcc -f -A "to: betadump@mycompany.com" | sendmail -t -i
Essentially, you call this script exactly like you would call sendmail. For example:
Code:
> echo "test mail" | ./mrewrite my@address.com
It works as far as:
- 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
I have read formail doc but I still don't see how. Is there a way to do that with formail or some bash scripting perhaps?