The OpenD Programming Language

IncomingEmailMessage

Represents a single email from an incoming or saved source consisting of the raw data. Such saved sources include mbox files (which are several concatenated together, see MboxMessages for a full reader of these files), .eml files, and Maildir entries.

Constructors

this
this(immutable(ubyte)[][] mboxLines, bool asmbox)
this(string[] lines)
this(immutable(ubyte)[] fileContent)

Various constructors for parsing an email message.

Members

Functions

extractGPGData
ubyte[] extractGPGData()
extractGPGSignature
immutable(ubyte)[] extractGPGSignature()
fromEmailAddress
string fromEmailAddress()
headers
const(HeadersHash) headers()

Allows access to the headers in the email as a key/value hash.

htmlMessageBody
string htmlMessageBody()
textMessageBody
string textMessageBody()

Returns the message body as either HTML or text. Gives the same results as through the parent interface, EmailMessage.htmlBody and EmailMessage.textBody.

toEmailAddress
string toEmailAddress()

Properties

hasGPGSignature
bool hasGPGSignature [@property getter]

Static functions

fromFile
IncomingEmailMessage fromFile(string filename)

Convenience method that takes a filename instead of the content.

Variables

gpgalg
string gpgalg;
gpgmime
MimePart gpgmime;
gpgproto
string gpgproto;
textAutoConverted
bool textAutoConverted;

Returns the message body as either HTML or text. Gives the same results as through the parent interface, EmailMessage.htmlBody and EmailMessage.textBody.

Inherited Members

From EmailMessage

setHeader
void setHeader(string name, string value, string file, size_t line)

Adds a custom header to the message. The header name should not include a colon and must not duplicate a header set elsewhere in the class; for example, do not use this to set To, and instead use the to field.

to
RecipientList to;
cc
RecipientList cc;
bcc
RecipientList bcc;

Recipients of the message. You can use operator ~= to add people to this list, or you can also use addRecipient to achieve the same result.

from
EmailRecipient from;
replyTo
EmailRecipient replyTo;

Represents the From: and Reply-To: header values in the email.

subject
string subject;

The Subject: header value in the email.

inReplyTo
string inReplyTo;

The In-Reply-to: header value. This should be set to the same value as the Message-ID header from the message you're replying to.

textBody
string textBody()
void textBody(string text)

Gets and sets the current text body.

htmlBody
string htmlBody()

Gets the current html body, if any.

linesep
string linesep;

If you use the send method with an SMTP server, you don't want to change this. While RFC 2045 mandates CRLF as a lineseperator, there are some edge-cases where this won't work. When passing the E-Mail string to a unix program which handles communication with the SMTP server, some (i.e. qmail) expect the system lineseperator (LF) instead. Notably, the google mail REST API will choke on CRLF lineseps and produce strange emails (as of 2024).

addRecipient
void addRecipient(string name, string email, ToType how)
addRecipient
void addRecipient(string who, ToType how)
setTextBody
void setTextBody(string text)

Sets the plain text body of the email. You can also separately call setHtmlBody to set a HTML body.

setHtmlBody
void setHtmlBody(string html)

Sets the HTML body to the mail, which can support rich text, inline images (see addInlineImage), etc.

addAttachment
void addAttachment(string mimeType, string filename, void[] content, string id)

The filename is what is shown to the user, not the file on your sending computer. It should NOT have a path in it.

addInlineImage
void addInlineImage(string id, string mimeType, string filename, void[] content)

in the html, use img src="cid:ID_GIVEN_HERE"

toString
string toString()

Returns the MIME formatted email string, including encoded attachments

send
void send(RelayInfo mailServer)

Sends via a given SMTP relay

Meta