Using the latest version of amavisd-new ([login to view URL]), I need a simple custom hook created that allows me to add a signature to every email, and to add a bit of custom html and/or plain text to every email that passes through the system.
Amavisd-new custom hooks are implemented in perl, and it appears a "before_send" hook is the appropriate place to implement this code. The "[login to view URL]" example in the amavisd-new code demonstrates how these custom hooks work.
This hook needs to:
1. Prepend some content to the beginning of every email.
2. Add a signature to the end of every email.
This must work with both the plain text and HTML portions of an email and support both single and multipart MIME encoded emails.
When modifying the plain text portion of the email, the content added would simply be offset by a string delimiter like "\n---------------\n". When modifying the HTML portion of an email, the new content would be included in a separate div, basically styled to set it apart from the rest of the message.
It must also support scenarios where the body content has been base64 encoded. I've seen this with certain paypal emails, for example, that contain a base64-encoded bit of HTML.
I will provide approximately 10 sample emails that should be tested for compatibility.
The code will need to properly parse out the various MIME boundaries and modify any plain text portions, and parse out any HTML code to properly add the prepended content after any "<body>" tag, and the signature before the closing "</body>" tag, so some basic HTML parsing may be required. You may want to use a cpan module like MIME::Signature or the like to assist.