Notify an administrator upon account creation

Have you ever wanted to run an external task or notify an administrator or similar when a new user has been created in MDaemon? This is actually possible via a content filter rule in MDaemon.

The content filter is found within the MDaemon GUI under Security | Content Filter, but it’s sometimes easier to modify the cfrules.dat to recreate a complicated rule. The cfrules.dat file is located within the \MDaemon\APP directory and can be modified using plain-text a editor, but please take a backup of this file first!

RuleName=Take action on new user welcome message
Condition01=X-Actual-From|starts with|AND|[email protected]|
Condition02=SUBJECT|contains|OR|Welcome to MDaemon!|Welcome to the email system|Email account information|
Condition03=X-Welcome-Message|does not exist|AND|
Action01=add header|"X-Welcome-Message","True"
Action02=copy to|"[email protected]"

Feel free to paste this to the bottom of your cfrules.dat file, save, and you can modify it within the content filter editor within the MDaemon GUI. Note that the rule will not be activated until you open the Content Filter and enable it.

If you’re asking yourself why there is a X-Welcome-Message header being created, it’s simple: If your action included sending an email to an external account that was forwarded back into MDaemon, you’d end up with a loop. By using a custom header, we can avoid that loop.

Lastly, verify that you have the option checked in MDaemon for ‘System generated messages are sent through the content and spam filters’ within MDaemon under Setup | Preferences | Miscellaneous.

While the rule in it’s current form is intended to copy the new-user message to a specific account, you can also run an external script or use other Content Filter actions instead.

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)

RuleName=If subject is NOT empty, Skip next rule
Condition01=SUBJECT|reg exp|AND|^..+$|
Action01=skip rule|"1"
RuleName=Subject IS empty!
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.

Detecting the use of BCC from the content filter

This is a simple content filter rule that will help you in filtering messages where the current destination was BCC’d rather then being listed in the TO or CC field.

Note that this will trip on most mailing lists — This is correct behaviour, unless the mailing list fills in the recipient’s name in the TO field (and most do not), lists are essentially using BCC.

It only works reliably in the LocalQ, it won’t work in the RemoteQ unless you turn off smartspooling, and it only works for mail received via SMTP, not MultiPOP or DomainPOP.

RuleName=Detect BCC’d messages
Condition01=TO|does not contain|AND|$HEADER:X-Rcpt-To$|
Condition02=CC|does not contain|AND|$HEADER:X-Rcpt-To$|
Action01=add header|”X-BCC”,”True”

To use this rule, copy the above text and paste it into the very top or very bottom of your MDaemonAppcfrules.dat file using Notepad, then open the content filter dialog in MDaemon and enable the rule.

No semaphore files needed, no need to restart MDaemon.