2
Command Line that execute after Spam Checks but before delivery?
Question asked by clyap - 3/21/2022 at 8:50 AM
Answered
I have a custom exe which can modify content of email (e.g. adding a cautionary message for external mail), which I tested successfully with "Command Line File" under General > Spool configuration, as well as under Antispam > Options > Enable spool proc folder (albeit a different architecture [windows service / file watcher], but same functionality)

I can get the intended result (e.g. adding a warning message to email body), but guess what, DKIM has failed for obvious reason.

So I'm wondering if there is a way to invoke an exe after spam checks?

I don't have in depth knowledge about DKIM / ARC, but let's say there's a way around the problem described above, would it cause other problems when the modified mail is forwarded (e.g. forwarded to external domains like gmail.com)?

Thank you very much for your time.

6 Replies

Reply to Thread
0
Zach Sylvester Replied
Employee Post
Hello, 

Thank you for reaching out to the community. 
How does your script work exactly? Does it just write to it when it pops into the proc folder? Does it only change incoming external messages or does it do outbound sending messages as well? Something that might work is after making the change you move the .eml to the drop folder then it would be resent. I tested putting a draft into the drop folder and it was delivered externally and passed DKIM. 

Please let me know if this helps. 

Kind Regards, 
Zach Sylvester System/Network Administrator SmarterTools Inc. (877) 357-6278 www.smartertools.com
0
clyap Replied
Hi Zach,

Thank you very much for your reply.

For outbound deliveries with modified body, yes, they were delivered successfully and passed DKIM checks at the recipient end. My problem is with the inbound mails.

My script reads the hdr file to determine if the mail is inbound or outbound; if the mail is inbound (containsLocalDeliveries=true), the script adds additional content to the html part / text part.

I note that at this stage, the eml file has not gone through spool filtering spam checks, as the
X-SmarterMail-Spam and X-SmarterMail-TotalSpamWeight headers are not yet available.

The spool filtering spam checks are only carried out after I placed the eml and hdr back to the drop folder / subspool folder, which is confirmed by the entries in delivery log and spamchecks log. Sample spamchecks log looks like the following:

07:49:55.558 [20374028] Running SPF check
07:49:55.558 [20374028] Finished SPF check; result = Pass
07:49:55.558 [20374028] [DKIM] Performing DKIM check...
07:49:55.558 [20374028] [DKIM] Result: Bad. Additional info: Hashes do not match.
07:50:04.074 [20374028] Spam Checks completed.
07:50:04.074 [20374028] SpamCheck Processing Thread Completed

Thank you!
0
clyap Replied
Hi,

For the case of Command Line File under General > Spool, the exe is invoked before spam checks.

It would be ideal if there is another option to have command line invoked after "Removed from SpamCheckQueue" and before "Added to LocalDeliveryQueue"

01:20:01.962 [20373318] Delivery started for sender@external.com at 1:20:01 AM
01:20:07.978 [20373318] Added to SpamCheckQueue (0 queued; 1/30 processing)
01:20:07.978 [20373318] [SpamCheckQueue] Begin Processing.
01:20:07.978 [20373318] Blocked Sender Checks started.
01:20:07.978 [20373318] Blocked Sender Checks completed.
01:20:08.024 [20373318] Launching 'E:\MailTools\Spanlogic.Net5.SMProc\Spanlogic.Net5.SMProc.exe' command line exe.
01:20:08.431 [20373318] Command line exe finished.
01:20:08.431 [20373318] Spam Checks started.
01:20:12.899 [20373318] Spam Check results: [REVERSE DNS LOOKUP: 0,Passed], ...
01:20:12.899 [20373318] Spam Checks completed.
01:20:12.899 [20373318] Removed from SpamCheckQueue (0 queued or processing)
01:20:13.978 [20373318] Added to LocalDeliveryQueue (0 queued; 1/50 processing)
01:20:13.978 [20373318] [LocalDeliveryQueue] Begin Processing.
01:20:13.978 [20373318] Starting local delivery to recipient@local.com
0
Zach Sylvester Replied
Employee Post Marked As Answer
Hello, 

Thanks for the follow-up. I see what you mean. One solution could be to use an inbound gateway and have the gateway do all the spam checks then once it's on your primary server you can disable the DKIM checks and add the line to your message. 

Please let me know if this helps. 

Kind Regards, 
Zach Sylvester System/Network Administrator SmarterTools Inc. (877) 357-6278 www.smartertools.com
0
clyap Replied
Hi Zach,

Thanks for your reply. Looks like for the time being that's the only solution for those installations that have an inbound gateway.

Thank you.
1
Zach Sylvester Replied
Employee Post
Hello, 

As you said you would need an inbound gateway. You can take a look at this guide and set it up without having to purchase a new key. https://portal.smartertools.com/kb/a2669/configure-smartermail-as-a-free-gateway-server.aspx

Kind Regards, 
Zach Sylvester System/Network Administrator SmarterTools Inc. (877) 357-6278 www.smartertools.com

Reply to Thread