xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_setmlreply.html (revision 4f29da19bd44f0e99f021510460a81bf754c21d2)
1<html>
2<head><title>smfi_setmlreply</title></head>
3<body>
4<!--
5$Id: smfi_setmlreply.html,v 1.1 2004/01/01 00:32:45 gshapiro 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=150>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</td>
84</tr>
85
86<!----------- Return values ---------->
87<tr>
88<th valign="top" align=left>RETURN VALUES</th>
89
90<td>smfi_setmlreply will fail and return MI_FAILURE if:
91<ul>
92    <li>The rcode or xcode argument is invalid.
93    <li>A memory-allocation failure occurs.
94    <li>If any text line contains a carraige return or line feed.
95    <li>The length of any text line is more than MAXREPLYLEN (980).
96    <li>More than 32 lines of text replies are given.
97</ul>
98Otherwise, it return MI_SUCCESS.
99</td>
100</tr>
101
102<!----------- Notes ---------->
103<tr align="left" valign=top>
104<th>NOTES</th>
105<td>
106<ul>
107<li>Values passed to smfi_setmlreply are not checked for standards compliance.
108<li>The message parameter should contain only printable characters,
109other characters may lead to undefined behavior.
110For example, CR or LF will cause the call to fail,
111single '%' characters will cause the text to be ignored
112(if there really should be a '%' in the string,
113use '%%' just like for <tt>printf(3)</tt>).
114<li>For details about reply codes and their meanings, please see RFC's
115<a href="http://www.rfc-editor.org/rfc/rfc821.txt">821</a>/
116<a href="http://www.rfc-editor.org/rfc/rfc2821.txt">2821</a>
117and
118<a href="http://www.rfc-editor.org/rfc/rfc1893.txt">1893</a>/
119<a href="http://www.rfc-editor.org/rfc/rfc2034.txt">2034</a>.
120<li>If the reply code (rcode) given is a '4XX' code but SMFI_REJECT is used
121for the message, the custom reply is not used.
122<li>Similarly, if the reply code (rcode) given is a '5XX' code but
123SMFI_TEMPFAIL is used for the message, the custom reply is not used.
124<BR>
125Note: in neither of the last two cases an error is returned to the milter,
126libmilter silently ignores the reply code.
127<li>
128If the milter returns SMFI_TEMPFAIL
129and sets the reply code to '421',
130then the SMTP server will terminate the SMTP session with a 421
131error code.
132</ul>
133</td>
134</tr>
135
136</table>
137
138<hr size="1">
139<font size="-1">
140Copyright (c) 2000, 2002-2003 Sendmail, Inc. and its suppliers.
141All rights reserved.
142<br>
143By using this file, you agree to the terms and conditions set
144forth in the LICENSE.
145</font>
146</body>
147</html>
148