SmtpClient

Low-level synchronous API for implementing SMTP clients.

SmtpClient handles: + TCP data transmission and buffers management + TLS/SSL channel encryption + SMTP protocol request/reply handling + transport layer exceptions

SmtpClient does NOT handle: * semantic class usage mistakes like bad commands sequences

Supported SMTP commands: NOOP, HELO, EHLO, MAIL, RSET, RCPT, DATA (data, dataBody), AUTH (auth, authPlain), STARTTLS, VRFY, EXPN QUIT

Supported authentication methods: PLAIN

Constructors

this
this(string host, ushort port)
Undocumented in source.

Members

Functions

auth
SmtpReply auth(SmtpAuthType authType)

Perform authentication (according to RFC 4954)

authLoginPassword
SmtpReply authLoginPassword(string password)

Sends base64-encode password

authLoginUsername
SmtpReply authLoginUsername(string login)

Sends base64-encoded login

authPlain
SmtpReply authPlain(string login, string password)

Send base64-encoded authentication data according to RFC 2245. Need to be performed after data method call;

connect
SmtpReply connect()

Performs socket connection establishment. connect is the first method to be called after SmtpClient instantiation.

data
SmtpReply data()

Low-level method to initiate sending of the message body. Must be called after rcpt method call.

dataBody
SmtpReply dataBody(string message)

Sends the body of message to server. Must be called after data method. Also dataBody sends needed suffix to signal about the end of the message body.

disconnect
void disconnect()

Performs clean disconnection from server. It is recommended to use disconnect after quit method which signals SMTP server about end of the session.

ehlo
SmtpReply ehlo()

Initial message to send after connection. Retrieves information about SMTP server configuration

expn
SmtpReply expn(string mailinglist)

EXPN expands mailing list on the server. If mailing list is not available for you, you receive appropriate error reply, else you receive a list of mailiing list subscribers.

getResponse
string getResponse(string command, string suffix)

Implementation of request/response pattern for easifying communication with SMTP server.

helo
SmtpReply helo()

Initial message to send after connection. Nevertheless it is recommended to use ehlo() instead of this method in order to get more information about SMTP server configuration.

mail
SmtpReply mail(string address)

Low-level method to initiate process of sending mail. This can be called either after connect or after helo/ehlo methods call.

noop
SmtpReply noop()

A no operation message. essage that does not invoke any specific routine on server, but still the reply is received.

parseReply
SmtpReply parseReply(string rawReply)

Parses server reply and converts it to 'SmtpReply' structure.

quit
SmtpReply quit()

Performs disconnection from server. In one session several mails can be sent, and it is recommended to do so. quit forces server to close connection with client.

rcpt
SmtpReply rcpt(string to)

Low-level method to specify recipients of the mail. Must be called after

receiveData
string receiveData()

Convenience method to receive data from socket as a string.

rset
SmtpReply rset()

This method cancels mail transmission if mail session is in progress (after mail method was called).

sendData
bool sendData(char[] data)

Convenience method to send whole buffer of data into socket.

starttls
SmtpReply starttls(EncryptionMethod enctype, bool verifyCertificate)

Send command indicating that TLS encrypting of socket data stream has started.

vrfy
SmtpReply vrfy(string username)

This method asks server to verify if the user's mailbox exists on server. You can pass username or <[e-mail]> as an argument. The result is a reply that contains e-mail of the user, or an error code.

Properties

address
Address address [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
authenticated
authenticated [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
secure
bool secure [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

_authenticated
bool _authenticated;
Undocumented in source.
_recvbuf
char[1024] _recvbuf;
Undocumented in source.
_secure
bool _secure;
Undocumented in source.
secureTransport
SocketSSL secureTransport;
Undocumented in source.
server
InternetAddress server;
Undocumented in source.
transport
Socket transport;
Undocumented in source.

Meta