$k. MailMessage

new MailMessage()

A mail message

Extends

Methods

(static) testConnection(throwExceptionsopt, testUserNameopt)

Tests the SMTP configuration of the volume

Parameters:
NameTypeAttributesDescription
throwExceptionsboolean<optional>

Control, whether a failing connection test throws its exception. Default: false.

testUserNamestring<optional>

The name of the user account. Required if the SMTP configuration requires authentication and more than one user is configured.

attach(attachment)

Attach a entity

Parameters:
NameTypeDescription
attachment$k.NetEntity
Inherited From
Throws:

If the entity is not a valid attachment

Type
$k.exception.TypeError

attachments() → {Array.<$k.NetEntity>}

Returns the attached entities

Returns:
Type: 
Array.<$k.NetEntity>

base64String() → {string}

Get the binay contents as base64-encoded string. Returns undefined if the contents is not binary

Returns:
Type: 
string

bcc() → {Array.<string>}

Get the blind carbon copy receivers ('bcc' field)

Returns:
Type: 
Array.<string>

cc() → {Array.<string>}

Get the carbon copy receivers ('cc' field)

Returns:
Type: 
Array.<string>

charset() → {string}

Returns the charset

Inherited From
Returns:
Type: 
string

contentDisposition() → {string}

Returns the content disposition

Returns:
Type: 
string

contentLength() → {number}

Returns the content length

Returns:
Type: 
number

contentType() → {string}

Returns the content type (only the media type part)

Returns:
Type: 
string

dataUrl() → {string}

Returns the entity bytes as a data URL, or undefined if the entity is not binary

Inherited From
Returns:
Type: 
string

date() → {Array.<date>}

Get the date ('date' field)

Since
  • 5.4.2
Returns:
Type: 
Array.<date>

debugString() → {string}

Prints the entity, except binary contents, for debugging purposes

Returns:
Type: 
string

filename() → {string}

Returns the filename part of the content disposition field

Inherited From
Returns:
Type: 
string

formData() → {object}

Get all form fields (multipart/form-data or application/x-www-form-urlencoded). The property names correspond to the field names. The property values are either strings (if the form is of type application/x-www-form-urlencoded) or NetEntities (multipart/form-data)

Inherited From
Returns:
Type: 
object

headerCharset()

Get the charset of the headers

headerField(fieldName) → {string}

Get the value of the field of the request header. Returns undefined if the field does not exist

Parameters:
NameTypeDescription
fieldNamestring
Returns:

The field value

Type: 
string

headerFields() → {object}

Get all fields of the request header. Field names are always lower case

Returns:
Type: 
object

isBinary() → {boolean}

True if the entity has binary contents

Inherited From
Returns:
Type: 
boolean

receiver() → {Array.<string>}

Get the receiver ('to' field)

Returns:
Type: 
Array.<string>

removeHeaderField(fieldName)

Removes the field of the request heade

Parameters:
NameTypeDescription
fieldNamestring
Since
  • 5.0.3

send(asyncopt)

Send the mail, using the SMTP configuration of the volume

Parameters:
NameTypeAttributesDescription
asyncboolean<optional>

True if the mail should be sent asynchronously, false if send() should block until the mail has been sent. Default is true.

sender() → {Array.<string>}

Get the sender

Returns:
Type: 
Array.<string>

setBcc(receivers)

Set the blind carbon copy receivers ('bcc' field)

Parameters:
NameTypeDescription
receivers

String or Array of strings

setCc(receivers)

Set the carbon copy receivers ('cc' field)

Parameters:
NameTypeDescription
receivers

String or Array of strings

setCharset(charset)

Set the charset

Parameters:
NameTypeDescription
charsetstring
Throws:

If the charset is unknown

Type
$k.exception.InvalidValue

setContentDisposition(contentDisposition)

Set the content disposition

Parameters:
NameTypeDescription
contentDispositionstring

setContentLength(length)

Set the content length

Parameters:
NameTypeDescription
lengthnumber

setContents(contents)

Set the contents of the entity. Also sets the content type and filename if known. The contents object can be a string, document ($k.TextDocument), a blob value ($k.Blob) or another NetEntity

Parameters:
NameTypeDescription
contents

Contents object

setContentType(mediaType, charsetopt)

Set the content type

Parameters:
NameTypeAttributesDescription
mediaTypestring

Media type of the contents

charsetstring<optional>

Charset of the contents

setDate(date)

Set the date ('date' field)

Parameters:
NameTypeDescription
date

Date (either as a date or a string)

Since
  • 5.4.2

setFilename(filename)

Set the filename part of the content disposition field

Parameters:
NameTypeDescription
filenamestring

setHeaderCharset(charset)

Set the charset of the headers

Parameters:
NameTypeDescription
charsetstring

Charset (encoding) of the headers

Throws:

If the charset is unknown

Type
$k.exception.InvalidValue

setHeaderField(fieldName, fieldValue)

Set the value of the field of the request header

Parameters:
NameTypeDescription
fieldNamestring
fieldValue
Throws:

If the value does not match the type of the field

Type
$k.exception.TypeError

setReceiver(receivers)

Set the receiver ('to' field)

Parameters:
NameTypeDescription
receivers

String or Array of strings

Throws:

If the value is not a valid receiver

Type
$k.exception.InvalidValue

setSender(sender)

Set the sender ('from' field)

Parameters:
NameTypeDescription
senderstring
Throws:

setSubject(subject)

Set the subject

Parameters:
NameTypeDescription
subjectstring
Throws:

If the value is not a valid subject

Type
$k.exception.InvalidValue

setText(text)

Set the text as the body

Parameters:
NameTypeDescription
textstring
Inherited From

setUserName(username)

Set the name of the user account. Required if the SMTP configuration requires authentication and more than one user is configured

Parameters:
NameTypeDescription
usernamestring

subject() → {string}

Get the subject

Returns:
Type: 
string

text(charsetopt) → {string}

Get the contents as string

Parameters:
NameTypeAttributesDescription
charsetstring<optional>

Charset of the characters. Required for binary entities. Optional for text entities.

Inherited From
Returns:
Type: 
string

userName() → {string}

Get the name of the user account

Returns:
Type: 
string