Improvements to Mail Filtering

I’ve been playing with the mail filtering in Usermin lately, primarily because I have a client who depends on it whom I eventually want to move to a Virtualmin server. Here are the improvements I NEED to make that happen.

  1. Ability to match multiple conditions (both AND and OR).
  2. Ability to execute a script if the condition(s) match.
  3. Ability to perform multiple actions if the conditions match.

Things that would be nice to have, but are not strictly essential:

  1. make the filtering option available in Virtualmin, so the admin can create filters for all users in the domain or apply the same filter(s) to all users in the domain without having to log into Usermin every time and re-create the filter for each user.
  2. Provide the ability to pass variables to the target script based on the email headers. For example, if the mail is addressed to someuser@domain.tld, provide the ability to pass $user=someuser@domain.tld to the target script.
  3. Provide automatic import of cPanel filters. All the information is in their .yaml files. (Actually, I think they’re just using re-badged Procmail.)

Where does Virtualmin / Usermin store the filter information? I may be able to script something for my own use that I wouldn’t dare release publicly without someone smarter than me checking it first.

Thanks,

Richard

To expand upon my first post, here is my situation.

A client uses a third-party job assignment system that emails tasks to field personnel.

To distinguish between task assignments and the more mundane mail, the client wants the email also sent as MMS to the employees’ mobile phones when it comes from the assignment system’s email domain AND when the subject is a high-priority one.

There actually are two domains that send the emails depending on what stage of the process the job is in (estimate, proposal, approved, scheduled, etc.), hence the need for OR. Either of the addresses should trigger the action. The AND is needed to select for high-priority subjects, although that’s less-critical because almost all the messages are high-priority.

So it’s something along the lines of

IF sender domain == (domain0 OR domain1)

AND

message subject == (subject0 OR subject1)

THEN DO (action0 AND action1)

The actions in this case are to send the MMS, and then send the original email.

We’d been using cPanel’s email filters for years to accomplish this, doing a simple forward to MMS followed by delivery via email (two actions when the trigger conditions are satisfied).

Then all of the sudden, it stopped working. The reason was that some idiot tagged an MMS message from the sending domain as spam somewhere along the line, and the client’s mobile carrier assigned the domain to some sort of SMS/MMS blocklist that they maintain: and no one there knows how to undo it.

After a week of getting nowhere with the carrier, I got an email inviting me to a Zoom meeting to address the problem. But they were dopey enough to put in the agenda that their “solution” involved subscribing to an absurdly expensive external mail service, from which the carrier no doubt gets a kickback.

“Screw that,” said I, followed by an anatomically-impossible suggestion to the carrier regarding a suitable destination for their Zoom meeting and the expensive third-party mail service.

Instead, I wrote a PHP script to explode the message, strip out the garbage, reformat it nicely for MMS, and send it as MMS. It then sends the original version as email. That’s why I suggest that Virtualmin’s mail filters be endowed with the ability to execute scripts.

I also suggest that the filters have the ability to pass variables. That would enable one script to be used for all users. The script could just look up the user’s mobile number from a database or flat file based on their email address, assign the email and the MMS address as variables for the mailer, format one version of the message for MMS, and send both the MMS and the original message on their way.

I’ll probably wind up cobbling together some code to do this in Virtualmin for my own use (in PHP, because my Perl sucks), but I think these would be useful enhancements to the existing filters.

Richard

That is something I would be interessted too.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.