xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_setreply.html (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1<HTML>
2<HEAD><TITLE>smfi_setreply</TITLE></HEAD>
3<BODY>
4<!--
5$Id: smfi_setreply.html,v 1.18 2013-11-22 20:51:39 ca Exp $
6-->
7<H1>smfi_setreply</H1>
8
9<TABLE border="0" cellspacing=4 cellpadding=4>
10<!---------- Synopsis ----------->
11<TR><TH valign="top" align=left width=100>SYNOPSIS</TH><TD>
12<PRE>
13#include &lt;libmilter/mfapi.h&gt;
14int smfi_setreply(
15	SMFICTX *ctx,
16	char *rcode,
17	char *xcode,
18	char *message
19);
20</PRE>
21Set the default SMTP error reply code.  Only 4XX and 5XX replies are accepted.
22</TD></TR>
23
24<!----------- Description ---------->
25<TR><TH valign="top" align=left>DESCRIPTION</TH><TD>
26<TABLE border="1" cellspacing=1 cellpadding=4>
27<TR align="left" valign=top>
28<TH width="80">Called When</TH>
29<TD>smfi_setreply may be called from any of the xxfi_ callbacks
30other than xxfi_connect.</TD>
31</TR>
32<TR align="left" valign=top>
33<TH width="80">Effects</TH>
34<TD>Directly set the SMTP error reply code for this connection.  This code
35will be used on subsequent error replies resulting from actions taken by
36this filter.</TD>
37</TR>
38</TABLE>
39</TD></TR>
40
41<!----------- Arguments ---------->
42<TR><TH valign="top" align=left>ARGUMENTS</TH><TD>
43    <TABLE border="1" cellspacing=0>
44    <TR bgcolor="#dddddd"><TH>Argument</TH><TH>Description</TH></TR>
45    <TR valign="top"><TD>ctx</TD>
46	<TD>Opaque context structure.
47	</TD></TR>
48    <TR valign="top"><TD>rcode</TD>
49	<TD>The three-digit (RFC 821/2821) SMTP reply code, as a
50	null-terminated string.  rcode cannot be NULL, and must be a valid
51	4XX or 5XX reply code.
52        </TD></TR>
53    <TR valign="top"><TD>xcode</TD>
54	<TD>The extended (RFC 1893/2034) reply code.  If xcode is NULL, no
55	extended code is used.  Otherwise, xcode must conform to RFC 1893/2034.
56	</TD></TR>
57    <TR valign="top"><TD>message</TD>
58	<TD>The text part of the SMTP reply.  If message is NULL, an empty message is used.
59	</TD></TR>
60    </TABLE>
61</TD></TR>
62
63<!----------- Return values ---------->
64<TR>
65<TH valign="top" align=left>RETURN VALUES</TH>
66
67<TD>smfi_setreply will fail and return MI_FAILURE if:
68<UL>
69    <LI>The rcode or xcode argument is invalid.
70    <LI>A memory-allocation failure occurs.
71    <LI>The length of any text line is more than MAXREPLYLEN (980).
72    <LI>The message argument contains a carriage return or line feed.
73</UL>
74Otherwise, it return MI_SUCCESS.
75</TD>
76</TR>
77
78<!----------- Notes ---------->
79<TR align="left" valign=top>
80<TH>NOTES</TH>
81<TD>
82<UL>
83<LI>Values passed to smfi_setreply are not checked for standards compliance.
84<LI>The message parameter should contain only printable characters,
85other characters may lead to undefined behavior.
86For example, CR or LF will cause the call to fail,
87single '%' characters will cause the text to be ignored
88(if there really should be a '%' in the string,
89use '%%' just like for <TT>printf(3)</TT>).
90<LI>For details about reply codes and their meanings, please see RFC's
91<A href="http://www.rfc-editor.org/rfc/rfc821.txt">821</A>/
92<A href="http://www.rfc-editor.org/rfc/rfc2821.txt">2821</A>
93and
94<A href="http://www.rfc-editor.org/rfc/rfc1893.txt">1893</A>/
95<A href="http://www.rfc-editor.org/rfc/rfc2034.txt">2034</A>.
96<LI>If the reply code (rcode) given is a '4XX' code but SMFI_REJECT is used
97for the message, the custom reply is not used.
98<LI>Similarly, if the reply code (rcode) given is a '5XX' code but
99SMFI_TEMPFAIL is used for the message, the custom reply is not used.
100<BR>
101Note: in neither of the last two cases an error is returned to the milter,
102libmilter silently ignores the reply code.
103<LI>If the milter returns SMFI_TEMPFAIL and sets the reply code to '421',
104then the SMTP server will terminate the SMTP session with a 421 error code.
105</UL>
106</TD>
107</TR>
108
109</TABLE>
110
111<HR size="1">
112<FONT size="-1">
113Copyright (c) 2000, 2002-2003 Proofpoint, Inc. and its suppliers.
114All rights reserved.
115<BR>
116By using this file, you agree to the terms and conditions set
117forth in the LICENSE.
118</FONT>
119</BODY>
120</HTML>
121