I am trying to use Procmail to filter through mail that goes to my ticket channel in WHMCS. It works fine as far as piping goes. But emails from the Zopim live chat module on the site need filtering and editing before they go to the script for WHMCS.
The emails as they come in are like so:
To: email@example.com From: Zopim <firstname.lastname@example.org> Subject: Offline Message from Visitor xxxx: xxx From: Visitor xxxxxx <email@example.com> URL: http://www.domain.com xxxxxxx ---- Zopim http://www.zopim.com
And here is my procmail rc file setup:
:0H * ^From: Zopim.*firstname.lastname@example.org | sed -e 's/^From: Zopim.*/From: me@me\.com/' | /usr/bin/php -q /var/www/pipe/pipe.php
Now, that is working fine, it's finding the
From field and replacing it with
email@example.com. The problem is I want to somehow get the text from inside the email where it says:
From: Visitor xxxxxx <firstname.lastname@example.org>
And put that above in the header where
From is at, so in essence it will be coming from the visitor and not zopim. This is where my problem lies, I can't figure out using sed or another program how to set that line as a Variable and replace it above, or just using sed to move lines around.