Detecting a blank header in the content filter

The content filter has a condition to trip if a header doesn’t exist.  However, there is no easy way to catch a header with no content at all.

This rule will trip on a blank subject header (where the header DOES exist, but has no content)

[Rule001]
RuleName=If subject is NOT empty, Skip next rule
Enable=Yes
ThisRuleCondition=All
ProcessQueue=LOCAL
Condition01=SUBJECT|reg exp|AND|^..+$|
Action01=skip rule|"1"
[Rule002]
RuleName=Subject IS empty!
Enable=Yes
ThisRuleCondition=All
ProcessQueue=LOCAL
Condition01=SUBJECT|exists|AND|
Action01=move to bad Msg|

UPDATE 2009/06/17: For some reason this rule was completely broken, both by WordPress inserting smartquotes, and a logic error. My apologies, it has been corrected and tested on MDaemon 10.0.5, it should now work as advertised.

Attaching HTML signatures

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/</html>","<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></html>","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.

UPDATED (2011/02/01): Made minor tweaks to content filter rule