Microsoft Defender engine needs Defender real-time protection, plus Command-Line Antivirus findings (and a documentation error)
Problem reported by Sabatino - 10/9/2026 at 2:32 AM
Being Fixed

Hi everyone,

While migrating our SmarterMail server to a new Windows Server 2025 VM, we spent some time testing the antivirus integrations. I’m sharing what we found because some of it isn’t documented and might save others a few hours.

Environment

  • SmarterMail 100.0.9756.27316, Windows Server 2025
  • Sophos Intercept X as the primary endpoint AV
  • Microsoft Defender real-time protection disabled by policy, so Defender stays in “Normal” mode with real-time, behavior monitoring, IOAV and on-access all off, to avoid running two real-time AVs side by side
  • ClamAV enabled in SmarterMail

1. The Microsoft Defender engine requires Defender real-time protection

On our old server, where Defender real-time protection is on, the Defender engine works: Defender’s threat history shows detections as amsi:_...\MailService.exe, so SmarterMail passes content to Defender through AMSI.

On the new server, with real-time protection off, an EICAR test sent via SMTP with ClamAV disabled is delivered without any detection. No error appears anywhere, and the engine just reports the message as clean. Enabling Sophos “AMSI Protection” does not help, since it targets script-based threats.

This isn’t mentioned in the documentation, and the admin UI shows no warning. If you run a third-party AV and disabled Defender real-time protection, your Defender engine is probably doing nothing.

2. Command-Line Antivirus: the script location in the documentation is wrong

The help page says the script must be in:
C:\Program Files (x86)\SmarterTools\SmarterMail\Service\Assets

SmarterMail actually launches it from:
C:\Program Files (x86)\SmarterTools\SmarterMail\Service\Settings\Assets

From the delivery log:


Launching 'C:/Program Files (x86)/SmarterTools/SmarterMail/Service/Settings/Assets/antiVirus.bat' command line exe.
Command line exe finished.

If the file is missing, it still logs “Command line exe finished” and raises no error, so it’s very easy to believe the scanner is running when it isn’t.

3. %FILEPATH is passed with forward slashes

The argument arrives as D:/SmarterMail/Spool/SubSpool2/235409001001.eml. MpCmdRun.exe does not accept that: it stops right after “Scan starting...” and returns exit code 2, which is also the code it uses for “threat found”. In a batch file you can convert it with:


set "SRC=%~1"
set "SRC=%SRC:/=\%"

4. File-based scanners don’t decode MIME, so the command-line approach can’t catch attachments

Even with the path fixed and the spool not excluded, both MpCmdRun.exe -Scan -ScanType 3 -File <eml> and Sophos’ sophosinterceptxcli.exe scan --expand_archives <eml> report an .eml with a base64-encoded EICAR attachment as clean. The same EICAR string in a plain file is detected immediately. File scanners don’t parse .eml/MIME, so a command-line scanner only helps if the product itself understands mail formats. The built-in engines work because SmarterMail extracts the content and hands it over: clamd for ClamAV, AMSI for Defender.

5. SmarterMail re-adds its Defender exclusions on every service start

After a restart we got the “Windows Defender Exclusions Added” notification. That’s useful, but worth knowing if you’re testing Defender exclusions by hand.

Suggestions for SmarterTools

  • Fix the Assets path in the Command-Line Antivirus documentation.
  • Pass %FILEPATH with Windows-style backslashes, or document the forward slashes.
  • Document that the Defender engine needs Defender real-time protection, and show a warning in the antivirus settings when it is off.
  • Log an error when the command-line script isn’t found.
  • Consider an option to pass extracted attachments to the command-line scanner, or to act on its exit code, so third-party file scanners become useful.

Is anyone else running the Defender engine alongside a third-party endpoint AV? How did you handle it?


Sabatino Traini
      Chief Information Officer
Genial s.r.l. 
Martinsicuro - Italy

John Quest Replied
Regarding 2 and 3: Yes, SM is aware after spending hours working on command line AV with me this week and they should be updating their documentation soon.

For 4, let me test that, as I am using ESET and I believe I have command line configured to allow it to find and extract attachments. I will have to test and report back.
Sabatino Replied
How do you handle the attachment extraction?
It’s a risky process and too prone to bugs—
unless ESET does it for you automatically.
I expected Defender to keep working with AMSI, especially since I had discussed it with SM and they said it would.
Sabatino Traini
      Chief Information Officer
Genial s.r.l. 
Martinsicuro - Italy

Douglas Foster Replied
On the subject of extraction:   I use the Python Email module to extract attachments.   I first used it to extract DMARC reports files from a DMARC aggregate report email.   Since then, we have extended the concept for other purposes.   But I am processing known-safe attachments, not hostile ones.

I am guessing that for your purposes, you need to extract to a folder that is exempt from real-time scanning, then invoke command-line scanning, then delete the sample.   Maybe have a script that wakes up at fixed intervals and delete everything more than a certain age.
John Quest Replied
OK, here is an example. This was an incoming email with an email attachment to it, which had a PDF attachement to that. The ESET command line properly identifies MIME segments, extracts them, scans them individually, and reports back overall.

Shay Jacobs Replied
Employee Post
Hello everyone! I just wanted to let you all know that I passed these findings along to the development team. Since issue number 2 is a simple documentation mistake, our writer will get that corrected right away. As for the other four problems, we are moving forward with verifying them and will implement fixes as soon as we can. Please keep your eye out for future release notes that address these issues!
Shay Jacobs
System/Network Administrator
SmarterTools Inc.
Sabatino Replied

Thanks Shay, and thanks John and Douglas for the input.

Thinking about it more, the command-line approach isn’t a bad idea compared to AMSI. It would let me use whichever antivirus I prefer, or even more than one.

But attachment extraction should be done by SmarterMail, not by each admin in a script. Douglas, your approach would work, but for hostile content I’d rather not own a MIME parser: it’s too risky given the bugs it could have now and in future versions, and running an extraction step on every message would hit performance.

SmarterMail already parses MIME for ClamAV and AMSI, so it would certainly do this better. ESET handles it on its own, as John showed, but Defender’s and Sophos’ command-line scanners don’t.

So my request would be an option for the Command-Line Antivirus to receive the extracted parts (each attachment, plus the decoded body) instead of only the raw .eml, and to act on the scanner’s exit code. That would make any file-based scanner usable without custom code.

Sabatino Traini
      Chief Information Officer
Genial s.r.l. 
Martinsicuro - Italy

John Quest Replied
So my request would be an option for the Command-Line Antivirus to receive the extracted parts (each attachment, plus the decoded body) instead of only the raw .eml, and to act on the scanner’s exit code. That would make any file-based scanner usable without custom code.

IMHO, that is beyond what SmarterMail should do for a hand off third party responsibility process.
Douglas Foster Replied
Seems like the best solution is to use a product that can parse the eml, or a locally-developed application that can parse the eml and send the attachments to an antivirus product through an API.  That way, the suspect file never exists on your network as an independent file.

No opinion on whether SM will build that someday, and no.opionion on whether Defender has an API that you can use.  But if you need it now, you probably need to build it yourself.


John Quest Replied
SmarterMail already parses MIME for ClamAV and AMSI, so it would certainly do this better. ESET handles it on its own, as John showed, but Defender’s and Sophos’ command-line scanners don’t.

Seems like Sophos has the ability to do that, although I have no direct knowledge or any way to test.
Sabatino Replied
Thanks, John Quest.
I’ll give it a try tomorrow.
Sabatino Traini
      Chief Information Officer
Genial s.r.l. 
Martinsicuro - Italy

Reply to Thread

Enter the verification text