juno.net.mail Module

Contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.

Licence
See licence.txt for use and distribution terms.

class SmtpException: object.Exception;

The exception thrown when the SmtpClient is unable to complete a send operation.

enum SmtpDeliveryMethod;



Network



PickupDirectory



class SmtpClient;

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.

class MailAddress;

Represents the address of an electronic mail sender or recipient.

this(string address);
this(string address, string displayName);

Initializes a new instance.

final char[] address();

Gets the e-mail address specified.

final char[] displayName();

Gets the display name specified.

final char[] user();

Gets the user information from the address specified.

final char[] host();

Gets the host portion of the address specified.

class MailAddressCollection: juno.base.collections.Collection!(MailAddress).Collection;

Stores e-mail addresses associated with an e-mail message.

class Attachment;

Represents an e-mail attachment.

this(string fileName);

Initializes a new instance.

final void fileName(char[] value);
final char[] fileName();

Gets or sets the name of the attachment file.

final void transferEncoding(TransferEncoding value);
final TransferEncoding transferEncoding();

Gets or sets the type of encoding of this attachment.

class AttachmentCollection: juno.base.collections.Collection!(Attachment).Collection;

Stores attachments to be sent as part of an e-mail message.

enum MailPriority;



Normal



Low



High



class MailMessage;

Represents an e-mail message that can be sent using the SmtpClient class.

this();
this(string from, string to);
this(string from, string to, string subject, string bodyText);
this(MailAddress from, MailAddress to);

Initializes a new instance.

final void from(MailAddress value);
final MailAddress from();

Gets or sets the from address.

final void sender(MailAddress value);
final MailAddress sender();

Gets or sets the sender's address.

final void replyTo(MailAddress value);
final MailAddress replyTo();

Gets or sets the ReplyTo address.

final MailAddressCollection to();

Gets the address collection containing the recipients.

final MailAddressCollection cc();

Gets the address collection containing the carbon copy (CC) recipients.

final MailAddressCollection bcc();

Gets the address collection containing the blind carbon copy (BCC) recipients.

final void priority(MailPriority value);
final MailPriority priority();

Gets or sets the priority.

final void subject(char[] value);
final char[] subject();

Gets or sets the subject line.

final NameValueCollection headers();

Gets the e-mail headers.

final void bodyText(char[] value);
final char[] bodyText();

Gets or sets the message body.

final void isBodyHtml(bool value);
final bool isBodyHtml();

Gets or sets whether the mail message body is in HTML.

final void bodyEncoding(Encoding value);
final Encoding bodyEncoding();

Gets or sets the encoding used to encode the message body.

final AttachmentCollection attachments();

Gets the attachment collection used to store data attached to this e-mail message.