Allows applications to send e-mail using the Simple Mail Transfer Protocol (SMTP).
Examples
string from = `"Ben" ben@btinternet.com`;
string to = `"John" john@gmail.com`;
auto message = new MailMessage(from, to);
message.subject = "Re: Last Night";
message.bodyText = "Had a blast! Best, Ben.";
string host = "smtp.btinternet.com";
auto client = new SmtpClient(host);
auto credentials = new CredentialCache;
credentials.add(client.host, client.port, "Basic", userName, password);
client.credentials = credentials;
try {
client.send(message);
}
catch (Exception e) {
writefln("Couldn't send the message: " ~ e.toString());
}
this();
this(string host);
this(string host, int port);
final void send(MailMessage message);
final void send(char[] from, char[] recipients, char[] subject, char[] bodyText);
- Sends an e-mail message to an SMTP server for delivery.
final void host(char[] value);
final char[] host();
- Gets or sets the name or IP address of the host used to send an e-mail message.
final void port(int value);
final int port();
- Gets or sets the port used to send an e-mail message. The default is 25.
final void deliveryMethod(SmtpDeliveryMethod value);
final SmtpDeliveryMethod deliveryMethod();
- Specifies how outgoing e-mail messages will be handled.
final void pickupDirectoryLocation(char[] value);
final char[] pickupDirectoryLocation();
- Gets or sets the folder where applications save mail messages.
final void credentials(ICredentialsByHost value);
final ICredentialsByHost credentials();
- Gets or sets the credentials used to authenticate the sender.
final void enableSsl(bool value);
final bool enableSsl();
- Specifies whether to use Secure Sockets Layer (SSL) to encrypt the connection.
final void timeout(int value);
final int timeout();
- Gets or sets the amount of time after which a send call times out.