Milter smfi_quarantine()

Quarantine a message V8.13 and later

V8.13 sendmail added a routine called smfi_quarantine() to the Milter library. It is used to quarantine (rather than to simply accept or reject) a message. Quarantining is described in Queue Quarantining on page 438.

This new routine may only be called from the xxfi_eom() (Milter xxfi_eom() on page 1215) end-of-message handling routine. But before you can use this smfi_quarantine() routine, you must declare your intention to do so by first adding the SMFIF_QUARANTINE flag to the flags part of the smfiDesc declaration:

struct smfiDesc smfilter =
{
    ...
    SMFIF_ADDHDRS|SMFIF_QUARANTINE,    /* flags */   ← add here

Note that the flags are bitwise-ORed together (the “|” character). Once this is done, you can use this new smfi_quarantine() routine inside your xxfi_eom() routine, like this:

ret = smfi_quarantine(ctx, reason);

The smfi_quarantine() routine’s first argument is a common context pointer, ctx. The next argument is reason, a string that will be recorded in the queue as the reason this message was quarantined. The string must be non-NULL and not empty.

For example, suppose your Milter screens for viruses and one was found:

ret = smfi_quarantine(ctx, "Possible virus found in message body");

The return value (the ret) will be MI_SUCCESS on success; otherwise it will be MI_FAILURE. This smfi_quarantine() routine can fail if reason is NULL or empty, or if there was a network error, or if SMFIF_QUARANTINE was not set in your smfiDesc

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.