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