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