NAME
smfi_setmlreply() — sets default SMTP error reply code to a multi-line response
SYNOPSIS
#include <libmilter/mfapi.h>
int smfi_setmlreply(
SMFICTX *ctx,
char *rcode,
char *xcode,
...
);
PARAMETERS
- ctx
Specifies the opaque context structure.
- rcode
Specifies the 3-digit (RFC 821/2821) SMTP reply code, as a
null-terminated string.
rcode
must not be a NULL value, and must be a valid
4XX
or
5XX
reply code.
- xcode
Specifies the extended (RFC 1893 or 2034) reply code.
An
xcode
must conform to RFC 1893/2034 code.
If
xcode
is set to NULL, an extended code is not used.
- ...
Specifies the remaining arguments, which are single lines of text.
A maximum of 32 arguments can be specified.
These arguments are
used as the text part of the SMTP reply.
The list must be terminated
with a NULL value.
DESCRIPTION
The
smfi_setmlreply()
routine directly sets the SMTP error reply code for a
connection.
Only
4XX
and
5XX
replies are accepted.
The list of arguments in
smfi_setmlreply()
must be terminated with a
NULL value.
smfi_setmlreply()
is used on subsequent errors
from the filter.
smfi_setmlreply()
can be called from any of the
xxfi_callback()
functions other than
xxfi_connect().
Notes
Values passed to
smfi_setmlreply()
are not checked for standards compliance.
The message parameter must contain only printable
characters; other characters may lead to undefined behavior.
For example, a CR or LF will cause the call to fail, single
%
(percentage) characters will cause the text to be ignored.
If a
%
is required
in a string, use the
%%
format.
For more information on reply codes and their meanings, see
RFC 821, 2821, 1893, and 2034.
If the reply code, that is,
rcode,
is given a
4XX
code but
SMFI_REJECT
is used for the message, the custom reply is not used.
Similarly, if
rcode
is given a
5XX
code but
SMFI_TEMPFAIL
is used for the message, the custom reply is not used.
Note:
In neither of the last two cases, an error is returned to
the Milter and
libmilter
silently ignores the reply code.
If the Milter returns
SMFI_TEMPFAIL
and sets the reply code to '421', the SMTP server terminates the SMTP
session with a '421' error code.
RETURN VALUE
smfi_setmlreply()
fails and returns
MI_FAILURE
for the following reasons:
Invalid
rcode
or
xcode
argument value.
Memory-allocation failure.
Carriage return or line feed in a text line.
Length of any text line is more than the
MAXREPLYLEN
value (980).
More than 32 lines of text replies are provided.
smfi_setmlreply
returns
MI_SUCCESS
on successful completion.
EXAMPLES
Consider the following sample code:
ret = smfi_setmlreply(ctx, "550", "5.7.0",
"Spammer access rejected",
"Please see our policy at:",
"http://www.example.com/spampolicy.html",
NULL);
The following is the SMTP response of the sample code:
550-5.7.0 Spammer access rejected
550-5.7.0 Please see our policy at:
550 5.7.0 http://www.example.com/spampolicy.html
AUTHOR
The
smfi_setmlreply()
routine was developed by the Sendmail Inc.