Attaching HTML signatures
Posted on March 25, 2008
Filed Under MDaemon | 9 Comments
MDaemon’s content filter has an “Append a corporate signature” rule which can be used to add a block of text to the bottom of message. However, if you attempt to use HTML, the HTML code gets inserted into plain text signatures too.
I created a content filter rule hack around this limitation.
Basically what this rule does is the following:
Action01) Add the “plain-text” version of the signature with a special tag (/zzz/)
Action02) Clean up the special tag from the plain-text version.
Action03) Remove most of the signature from the HTML version.
Action04) Remove the rest of the signature from the HTML version and insert the HTML signature.
So, if you’re feeling brave, backup your \MDaemon\App\ directory and get started.
To “install” this content filter rule, copy the below lines and paste them into the very top of very bottom of your \MDaemon\App\cfrules.dat file, then go into MDaemon’s Content Filter and activate the rule.
[Rule001]
RuleName=HTML sig - TEST RULE
Enable=No
ThisRuleCondition=All
ProcessQueue=BOTH
Condition01=FROM|contains local account|AND|
Action01=add footer|"/zzz/1 corporate signature/zzz/","/zzz/2 corporate signature/zzz/","/zzz/3 corporate signature/zzz/"
Action02=body search and replace|"^/zzz/(.*)/zzz/$","\1","0,1"
Action03=body search and replace|"(<br>|^)/zzz/.*/zzz/<br>","","0,1"
Action04=body search and replace|"(<br>|^)/zzz/.*/zzz/</body>","<br><font color="#ff0000"><i>1 corporate signature</i></font><br><font color="#3366ff" size="-2">2 corporate signature</font><br><a href="http://www.example.com/">3 corporate signature</a><br></body>","0,1"
The rule is hardcoded to only function if a message is FROM a local account, but you’ll want to test this in your environment to make sure that no other mail gets a signature added. I’d suggest adding a “If the TO HEADER contains” condition to test the rule.
After “installing” the rule, open the rule in the Content Filter GUI editor (MDaemon –> Security –> Content Filter), edit the rule, then edit the “then add footer” (Action01) section to contain your corporate signature. However, add a /zzz/ to the start and end of each line. In other words, if you want your signature to look like this:
–
My Name
My Title
My Company
www.example.com
then what you’d enter would be
/zzz/– /zzz/
/zzz/My Name/zzz/
/zzz/My Title/zzz/
/zzz/My Company/zzz/
/zzz/www.example.com/zzz/
Don’t worry, the /zzz/ won’t show up to users, this is just a trick to allow the following actions to identify the signature. Action02 cleans up the /zzz/ code from the plain text version.
Action03 and Action04 are where the “magic” happens, these actions modify the HTML portion of the message and remove the signature we just finished adding, and then Action04 adds the HTML version of the signature.
Edit the very last “and body – search and replace” condition, don’t touch the “Search Expression” at all, only change the “Replace With”, replace it with your corporate signature, and add a tag to the end.
Hopefully this works, it appears to work in my own testing, but I’d appreciate comments if you either are successful, or can’t get it working. Please comment here, don’t use the “Feedback” link requesting technical support.
Note that while you can add HTML, it’s not yet possible to add a corporate logo — You can link to an image on the web, but many/most mail clients won’t display said image.
Comments
9 Responses to “Attaching HTML signatures”
Leave a Reply
Hey,
Thanks a lot for this, been trying to find out how to use HTML signatures for a while!
Say for example, I’m trying to add a small company logo to it, is it possible to attach a hyperlink for an image?
Oh, please ignore my last question, I failed to notice that images are not yet working.
I might play around with this a little and see if it’s possible to get it working.
Thanks a lot!
Grant, hyperlinking to an image works great, except that most modern mail clients won’t show the image unless the user clicks the “Show remote images” button (or equivalent)
In theory, appending an attachment is probably possible, but I haven’t found a way to do so reliably yet.
I do not believe this
fornetti, what don’t you believe?
I’ve completely disabled Content Filter from the options, but CFEngine.exe still takes 90% of the CPU resources when there are a bunch of messages in queue, I can’t understand why CFEngine.exe is still being executed?
Waseem, CFEngine is responsible for a lot more then just user created content rules.
Among other things, CFEngine is responsible for MDaemon’s antivirus, spam filtering, DK/DKIM signing, as well as hashcash.
I’d suggest looking at your hashcash settings, if you’re signing outbound messages with hashcash tokens then you’ll definitely see high CPU usage as hashcash is intentionally CPU intensive.
is it possible query Active Directory to add as signature the information like name surname title telephone number ect?
Hi,
I tried your codings exactly as is but didn’t work as expected. The recipient received the email with the signature of a single line below:
/zzz/3 corporate signature/zzz/
Appreciate if you could enlighten me what could have gone wrong?
vic