1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3 4<html> 5 6<head> 7 8<title>Postfix XCLIENT Howto</title> 9 10<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> 11 12</head> 13 14<body> 15 16<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix XCLIENT Howto</h1> 17 18<hr> 19 20<h2>Purpose of the XCLIENT extension to SMTP</h2> 21 22<p> When an SMTP server announces support for the XCLIENT command, 23an SMTP client may send information that overrides one or more 24client-related session attributes. The XCLIENT command targets the 25following problems: </p> 26 27<ol> 28 29 <li> <p> Access control tests. SMTP server access rules are 30 difficult to verify when decisions can be triggered only by 31 remote clients. In order to facilitate access rule testing, 32 an authorized SMTP client test program needs the ability to 33 override the SMTP server's idea of the SMTP client hostname, 34 network address, and other client information, for the entire 35 duration of an SMTP session. </p> 36 37 <li> <p> Client software that downloads mail from an up-stream 38 mail server and injects it into a local MTA via SMTP. In order 39 to take advantage of the local MTA's SMTP server access rules, 40 the client software needs the ability to override the SMTP 41 server's idea of the remote client name, client address and 42 other information. Such information can typically be extracted 43 from the up-stream mail server's Received: message header. </p> 44 45 <li> <p> Post-filter access control and logging. With 46 Internet->filter->MTA style content filter applications, 47 the filter can be simplified if it can delegate decisions 48 concerning mail relay and other access control to the MTA. This 49 is especially useful when the filter acts as a transparent 50 proxy for SMTP commands. This requires that the filter can 51 override the MTA's idea of the SMTP client hostname, network 52 address, and other information. </p> 53 54</ol> 55 56<h2>XCLIENT Command syntax</h2> 57 58<p> An example client-server conversation is given at the end 59of this document. </p> 60 61<p> In SMTP server EHLO replies, the keyword associated with this 62extension is XCLIENT. It is followed by the names of the attributes 63that the XCLIENT implementation supports. </p> 64 65<p> The XCLIENT command may be sent at any time, except in the 66middle of a mail delivery transaction (i.e. between MAIL and DOT, 67or MAIL and RSET). The XCLIENT command may be pipelined when the 68server supports ESMTP command pipelining. To avoid triggering 69spamware detectors, the command should be sent at the end of a 70command group. </p> 71 72<p> The syntax of XCLIENT requests is described below. Upper case 73and quoted strings specify terminals, lowercase strings specify 74meta terminals, and SP is whitespace. Although command and attribute 75names are shown in upper case, they are in fact case insensitive. 76</p> 77 78<blockquote> 79<p> 80 xclient-command = XCLIENT 1*( SP attribute-name"="attribute-value ) 81</p> 82<p> 83 attribute-name = ( NAME | ADDR | PORT | PROTO | HELO | LOGIN ) 84</p> 85<p> 86 attribute-value = xtext 87</p> 88</blockquote> 89 90<ul> 91 92 <li> <p> Attribute values are xtext encoded as per <a href="http://tools.ietf.org/html/rfc1891">RFC 1891</a>. 93 </p> 94 95 <li> <p> The NAME attribute specifies an SMTP client hostname 96 (not an SMTP client address), [UNAVAILABLE] when client hostname 97 lookup failed due to a permanent error, or [TEMPUNAVAIL] when 98 the lookup error condition was transient. </p> 99 100 <li> <p> The ADDR attribute specifies an SMTP client numerical 101 IPv4 network address, an IPv6 address prefixed with IPV6:, or 102 [UNAVAILABLE] when the address information is unavailable. 103 Address information is not enclosed with []. </p> 104 105 <li> <p> The PORT attribute specifies the SMTP client TCP port 106 number as a decimal number, or [UNAVAILABLE] when the information 107 is unavailable. </p> 108 109 <li> <p> The PROTO attribute specifies either SMTP or ESMTP. 110 </p> 111 112 <li> <p> The HELO attribute specifies an SMTP HELO parameter 113 value, or the value [UNAVAILABLE] when the information is 114 unavailable. </p> 115 116 <li> <p> The LOGIN attribute specifies a SASL login name, or 117 the value [UNAVAILABLE] when the information is unavailable. 118 </p> 119 120</ul> 121 122<p> Note 1: syntactically valid NAME and HELO attribute-value 123elements can be up to 255 characters long. The client must not send 124XCLIENT commands that exceed the 512 character limit for SMTP 125commands. To avoid exceeding the limit the client should send the 126information in multiple XCLIENT commands; for example, send NAME 127and ADDR first, then HELO and PROTO. </p> 128 129<p> Note 2: [UNAVAILABLE], [TEMPUNAVAIL] and IPV6: may be specified 130in upper case, lower case or mixed case. </p> 131 132<p> Note 3: Postfix implementations prior to version 2.3 do not 133xtext encode attribute values. Servers that wish to interoperate 134with these older implementations should be prepared to receive 135unencoded information. </p> 136 137<p> Note 4: Some Postfix implementations do not implement the PORT 138or LOGIN attributes. </p> 139 140<h2>XCLIENT Server response</h2> 141 142<p> Upon receipt of a correctly formatted XCLIENT command, the 143server resets state to the initial SMTP greeting protocol stage. 144Depending on the outcome of optional access decisions, the server 145responds with 220 or with a suitable rejection code. 146 147<p> For practical reasons it is not always possible to reset the 148complete server state to the initial SMTP greeting protocol stage: 149</p> 150 151<ul> 152 153<li> <p> TLS session information may not be reset, because turning off 154TLS leaves the connection in an undefined state. Consequently, the 155server may not announce STARTTLS when TLS is already active, and 156access decisions may be influenced by client certificate information 157that was received prior to the XCLIENT command. </p> 158 159<li> <p> The SMTP server must not reset attributes that were received 160with the last XCLIENT command. This includes HELO or PROTO attributes. 161</p> 162 163</ul> 164 165<p> NOTE: Postfix implementations prior to version 2.3 do not jump 166back to the initial SMTP greeting protocol stage. These older 167implementations will not correctly simulate connection-level access 168decisions under some conditions. </p> 169 170<h2> XCLIENT server reply codes </h2> 171 172<blockquote> 173 174<table border="1" bgcolor="#f0f0ff"> 175 176<tr> <th> Code </th> <th> Meaning </th> </tr> 177 178<tr> <td> 220 </td> <td> success </td> </tr> 179 180<tr> <td> 421 </td> <td> unable to proceed, disconnecting </td> </tr> 181 182<tr> <td> 501 </td> <td> bad command parameter syntax </td> </tr> 183 184<tr> <td> 503 </td> <td> mail transaction in progress </td> </tr> 185 186<tr> <td> 550 </td> <td> insufficient authorization </td> </tr> 187 188<tr> <td> other </td> <td> connection rejected by connection-level 189access decision </td> </tr> 190 191</table> 192 193</blockquote> 194 195<h2>XCLIENT Example</h2> 196 197<p> In the example, the client impersonates a mail originating 198system by passing all SMTP client information via the XCLIENT 199command. Information sent by the client is shown in bold font. 200</p> 201 202<blockquote> 203<pre> 204220 server.example.com ESMTP Postfix 205<b>EHLO client.example.com</b> 206250-server.example.com 207250-PIPELINING 208250-SIZE 10240000 209250-VRFY 210250-ETRN 211250-XCLIENT NAME ADDR PROTO HELO 212250 8BITMIME 213<b>XCLIENT NAME=spike.porcupine.org ADDR=168.100.189.2</b> 214220 server.example.com ESMTP Postfix 215<b>EHLO spike.porcupine.org</b> 216250-server.example.com 217250-PIPELINING 218250-SIZE 10240000 219250-VRFY 220250-ETRN 221250-XCLIENT NAME ADDR PROTO HELO 222250 8BITMIME 223<b>MAIL FROM:<wietse@porcupine.org></b> 224250 Ok 225<b>RCPT TO:<user@example.com></b> 226250 Ok 227<b>DATA</b> 228354 End data with <CR><LF>.<CR><LF> 229<b>. . .<i>message content</i>. . .</b> 230<b>.</b> 231250 Ok: queued as 763402AAE6 232<b>QUIT</b> 233221 Bye 234</pre> 235</blockquote> 236 237<h2>Security</h2> 238 239<p> The XCLIENT command changes audit trails and/or SMTP client 240access permissions. Use of this command must be restricted to 241authorized SMTP clients. </p> 242 243<h2>SMTP connection caching</h2> 244 245<p> XCLIENT attributes persist until the end of an SMTP session. 246If one session is used to deliver mail on behalf of different SMTP 247clients, the XCLIENT attributes need to be reset as appropriate 248before each MAIL FROM command. </p> 249 250<h2> References </h2> 251 252<p> Moore, K, "SMTP Service Extension for Delivery Status Notifications", 253<a href="http://tools.ietf.org/html/rfc1891">RFC 1891</a>, January 1996. </p> 254 255</body> 256 257</html> 258