PPoossttffiixx XXCCLLIIEENNTT HHoowwttoo

-------------------------------------------------------------------------------

PPuurrppoossee ooff tthhee XXCCLLIIEENNTT eexxtteennssiioonn ttoo SSMMTTPP

The XCLIENT command targets the following problems:

 1. Access control tests. SMTP server access rules are difficult to verify when
    decisions can be triggered only by remote clients. In order to facilitate
    access rule testing, an authorized SMTP client test program needs the
    ability to override the SMTP server's idea of the SMTP client hostname,
    network address, and other client information, for the entire duration of
    an SMTP session.

 2. Client software that downloads mail from an up-stream mail server and
    injects it into a local MTA via SMTP. In order to take advantage of the
    local MTA's SMTP server access rules, the client software needs the ability
    to override the SMTP server's idea of the remote client name, client
    address and other information. Such information can typically be extracted
    from the up-stream mail server's Received: message header.

 3. Post-filter access control and logging. With Internet->filter->MTA style
    content filter applications, the filter can be simplified if it can
    delegate decisions concerning mail relay and other access control to the
    MTA. This is especially useful when the filter acts as a transparent proxy
    for SMTP commands. This requires that the filter can override the MTA's
    idea of the SMTP client hostname, network address, and other information.

XXCCLLIIEENNTT CCoommmmaanndd ssyynnttaaxx

Examples of client-server conversations are given at the end of this document.

In SMTP server EHLO replies, the keyword associated with this extension is
XCLIENT. It is followed by the names of the attributes that the XCLIENT
implementation supports.

The XCLIENT command may be sent at any time except in the middle of a mail
delivery transaction (i.e. between MAIL and DOT). The XCLIENT command may be
pipelined when the server supports ESMTP command pipelining.

The syntax of XCLIENT requests is described below. Upper case and quoted
strings specify terminals, lowercase strings specify meta terminals, and SP is
whitespace. Although command and attribute names are shown in upper case, they
are in fact case insensitive.

    xclient-command = XCLIENT 1*( SP attribute-name"="attribute-value )

    attribute-name = ( NAME | ADDR | PROTO | HELO )

  * The NAME attribute specifies an SMTP client hostname (not an SMTP client
    address), [UNAVAILABLE] when client hostname lookup failed due to a
    permanent error, or [TEMPUNAVAIL] when the lookup error condition was
    transient.

  * The ADDR attribute specifies an SMTP client numerical IPv4 network address,
    an IPv6 address prefixed with IPV6:, or [UNAVAILABLE] when the address
    information is unavailable. Address information is not enclosed with [].

  * The PROTO attribute specifies either SMTP or ESMTP.

  * The HELO attribute specifies an SMTP HELO parameter value, or the value
    [UNAVAILABLE] when the information is unavailable.

Note 1: syntactically valid NAME and HELO attributes can be up to 255
characters long. The client must not send XCLIENT commands that exceed the 512
character limit for SMTP commands. To avoid exceeding the limit the client
should send the information in multiple XCLIENT commands.

Note 2: [UNAVAILABLE], [TEMPUNAVAIL] and IPV6: may be specified in upper case,
lower case or mixed case.

The XCLIENT server reply codes are as follows:

     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    |CCooddee|MMeeaanniinngg                         |
    |_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
    |250 |success                         |
    |_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
    |501 |bad command parameter syntax    |
    |_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
    |503 |mail transaction in progress    |
    |_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
    |421 |unable to proceed, disconnecting|
    |_ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |

XXCCLLIIEENNTT EExxaammpplleess

In the first example, the client impersonates a mail originating system by
passing all SMTP session information via XCLIENT commands. Information sent by
the client is shown in bold font.

    220 server.example.com ESMTP Postfix
    EEHHLLOO cclliieenntt..eexxaammppllee..ccoomm
    250-server.example.com
    250-PIPELINING
    250-SIZE 10240000
    250-VRFY
    250-ETRN
    250-XCLIENT NAME ADDR PROTO HELO
    250 8BITMIME
    XXCCLLIIEENNTT NNAAMMEE==ssppiikkee..ppoorrccuuppiinnee..oorrgg AADDDDRR==116688..110000..118899..22 PPRROOTTOO==EESSMMTTPP
    250 Ok
    XXCCLLIIEENNTT HHEELLOO==ssppiikkee..ppoorrccuuppiinnee..oorrgg
    250 Ok
    MMAAIILL FFRROOMM::<<wwiieettssee@@ppoorrccuuppiinnee..oorrgg>>
    250 Ok
    RRCCPPTT TTOO::<<uusseerr@@eexxaammppllee..ccoomm>>
    250 Ok
    DDAATTAA
    354 End data with <CR><LF>.<CR><LF>
    .. .. ..mmeessssaaggee ccoonntteenntt.. .. ..
    ..
    250 Ok: queued as 763402AAE6
    QQUUIITT
    221 Bye

In the second example, the client impersonates a mail originating system by
sending the XCLIENT command before the EHLO or HELO command. This increases the
realism of impersonation, but requires that the client knows ahead of time what
XCLIENT options the server supports.

    220 server.example.com ESMTP Postfix
    XXCCLLIIEENNTT NNAAMMEE==ssppiikkee..ppoorrccuuppiinnee..oorrgg AADDDDRR==116688..110000..118899..22
    250 Ok
    HHEELLOO ssppiikkee..ppoorrccuuppiinnee..oorrgg
    250 server.example.com
    MMAAIILL FFRROOMM::<<wwiieettssee@@ppoorrccuuppiinnee..oorrgg>>
    250 Ok
    RRCCPPTT TTOO::<<uusseerr@@eexxaammppllee..ccoomm>>
    250 Ok
    DDAATTAA
    354 End data with <CR><LF>.<CR><LF>
    .. .. ..mmeessssaaggee ccoonntteenntt.. .. ..
    ..
    250 Ok: queued as CF1E52AAE7
    QQUUIITT
    221 Bye

SSeeccuurriittyy

The XCLIENT command changes audit trails and/or SMTP client access permissions.
Use of this command must be restricted to authorized SMTP clients. However, the
XCLIENT command should not override its own access control mechanism.

SSMMTTPP ccoonnnneeccttiioonn ccaacchhiinngg

XCLIENT attributes persist until the end of an SMTP session. If one session is
used to deliver mail on behalf of different SMTP clients, the XCLIENT
attributes need to be reset as appropriate before each MAIL FROM command.

