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