Class SMTP.

Inherits SaslConnection. Inherited by LMTP and SMTPSubmit.

The SMTP class implements a basic SMTP server.

This is not a classic MTA. It implements all that's needed to deliver to local users, and for local users to submit messages to others. Nothing more.

This class implements SMTP as specified by RFC 2821, with the extensions specified by RFC 1651 (EHLO), RFC 1652 (8BITMIME), RFC 2487 (STARTTLS), RFC 2554 (AUTH), RFC 3030 (BINARYMIME and CHUNKING) and RFC 4468 (BURL).

SMTP::SMTP( int s, Dialect dialect )

Constructs an (E)SMTP server for socket s, speaking dialect.

void SMTP::addRecipient( SmtpRcptTo * r )

Notifies this SMTP server that r is a valid rcpt to command. SMTP records that so the LMTP SmtpData command can use the list later.

void SMTP::authenticated( User * user )

Sets this server's authenticated user to user.

EString SMTP::body() const

Returns what setBody() set. Used for SmtpBdat instances to coordinate the body.

Dialect SMTP::dialect() const

Returns the dialect used, ie. SMTP, LMTP or SMTP/Submit.

void SMTP::execute()

Runs all outstanding commands. When the oldest command is done, execute() removes it from the list and sends its responses to the client.

EString SMTP::heloName() const

Returns the recorded HELO name, as recorded by setHeloName(). The initial value is an empty string.

InputState SMTP::inputState() const

Returns the current input state, which is Command initially.

bool SMTP::isFirstCommand( SmtpCommand * c ) const

Returns true if c is the oldest command in the SMTP server's queue of outstanding commands, and false if the queue is empty or there is a command older than c in the queue.

void SMTP::parse()

Parses the SMTP/LMTP input stream.

void SMTP::parseCommand()

Reads a single SMTP/LMTP/Submit command from the client and creates an execution object for it.

Line length is limited to 4096 (for SMTP commands, not for message bodies): RFC 2821 section 4.5.3 says 512 is acceptable and various SMTP extensions may increase it. RFC 2822 declares that line lengths should be limited to 998 characters.

List<Address> * SMTP::permittedAddresses()

Returns a pointer to the list of addresses the currently authenticated User is permitted to use, or a null pointer if the list is not yet known.

List<SmtpRcptTo> * SMTP::rcptTo() const

Returns a list of all valid SmtpRcptTo commands. This is never a null pointer, but may be an empty list.

void SMTP::reset()

Resets most transaction variables, so a new mail from/rcpt to/data cycle can begin. Leaves the heloName() untouched, since some clients do not resend helo/ehlo/lhlo.

void SMTP::setBody( const EString & b )

Records b for later recall. reset() clears this.

void SMTP::setHeloName( const EString & name )

Records that the client claims to be called name. name isn't used for anything, just logged and recorded in any received fields generated.

void SMTP::setInputState( InputState s )

Notifies this SMTP server that its input state is now s. If the state is anything other than Command, the SMTP server calls the last SmtpCommand every time there's more input. Eventually, the SmtpCommand has to call setInputState( Command ) again.

void SMTP::setTransactionId( const EString & id )

Uses id as transaction id for this message. Reset by rset. Used for debugging.

void SMTP::setTransactionTime( Date * now )

Records the current time, now. The rest of the SMTP transaction will be considered to happen at the specified time. Used for debugging, when we want mail to be injected at known times.

Sieve * SMTP::sieve() const

Returns a pointer to the Sieve that manages local delivery for this SMTP server.

EString SMTP::transactionId()

Return an ESMTP id, either based on an internal algorithm or on something the client specified using an Archiveopteryx-specific extension.

This function returns the same ID even if called several times. Rset resets it.

Date * SMTP::transactionTime() const

Returns the current time and date, except that if you call it more than once for the same object, it returns the same value.

User * SMTP::user() const

Returns a pointer to the authenticated user, or a null pointer if the connection is unauthenticated.

Reimplements SaslConnection::user().

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.