smfi_setreply Function

Purpose

The smfi_setreply function sets the default simple mail transfer protocol (SMTP) error reply code and accepts only 4XX and 5XX reply codes.

Syntax

#include <libmilter/mfapi.h>
int smfi_setreply
SFICTX *ctx,
char *rcode,
char *xcode,
char *message
);

Description

The smfi_setreply function is called from any of the xxfi_ callback functions other than the xxfi_connect function. The smfi_setreply function sets the SMTP error reply code for the connection. This code is used for subsequent error replies resulting from actions taken by this filter.

The values passed to the smfi_setreply function are not checked for standards compliance.

The message argument must contain only printable characters. Other characters can lead to undefined behavior. For example, characters like CR or LF causes the call to fail, single '%' characters causes the text to be ignored.
Note: If a '%' string is required in the parameter use '%%' just like for printf(3).

For details about reply codes and their meanings, see RFC 821 or 2821 and RFC 1893 or 2034.

If the rcode argument is set as 4XX but, the SMFI_REJECT value is used for the message, the custom reply is not used.

If the rcode argument is set as 5XX but, the SMFI_TEMPFAIL value is used for the message, the custom reply is not used.
Note: In the above two cases an error is returned to the milter parameter. The Libmilter parameter ignores the above reply code.

If the milter parameter returns the SMFI_TEMPFAIL value and sets the reply code to 421, the SMTP server terminates the SMTP session with a 421 error code.

Arguments

Table 1. Arguments
Item Description
ctx The opaque context structure is maintained in the libmilter parameter.
rcode The three-digit ( RFC 821 or 2821) SMTP reply code is a null-terminated string. rcode cannot be NULL, and must be a valid 4XX or 5XX reply code.
xcode The extended (RFC 1893 or 2034) reply code. If xcode is NULL, extended code is not used. Otherwise, xcode must conform to RFC 1893 or 2034.
message The text part of the SMTP reply. If message is NULL, an empty message is used.

Return values

The smfi_setreply function returns the MI_FAILURE value in the following cases. Otherwise, the function returns MI_SUCCESS.
  • The rcode or xcode argument is invalid.
  • A memory-allocation failure occurs.

Related information

libmilter_xxfi_connect.html