gdDocumentation0.8.0

API reference

GD.mail

Parse mail addresses, dates, and headers, and submit messages over SMTP. STARTTLS upgrades the existing connection without falling back to plaintext. MIME helpers are under GD.mail.mime.

Properties

mime : GD.mail.mime

Parse and format MIME media types, encoded words, quoted-printable bytes, and multipart bodies.

Methods

parse_address

parse_address(text: String) -> Dictionary, Err

Parse one display name and mailbox.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

Dictionary, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

parse_address_list

parse_address_list(text: String) -> Array, Err

Parse comma-separated mailboxes without discarding display names.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

Array, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

parse_date

parse_date(text: String) -> Dictionary, Err

Parse a mail date while retaining its numeric timezone offset.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

Dictionary, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

read_message

read_message(data: PackedByteArray) -> GDMailMessage, Err

Split a mail message into repeated headers and its untouched body bytes.

Parameters

NameTypeDefaultDescription
dataPackedByteArrayRequiredInput data in the representation shown by the parameter type.

Return value

GDMailMessage, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

read_message_async

read_message_async(source: Variant) -> await GDMailMessage, Err

Parse headers from bytes or a readable stream without collecting the whole body.

Parameters

NameTypeDefaultDescription
sourceVariantRequiredMessage byte source providing read_async(max_bytes).

Return value

await GDMailMessage, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

plain_auth

plain_auth(user: String, password: String, identity: String = "") -> Dictionary

Package PLAIN credentials for a verified SMTP session.

Parameters

NameTypeDefaultDescription
userStringRequiredSMTP authentication user name.
passwordStringRequiredPassword bytes used as key-derivation input.
identityString""Optional authorization identity for PLAIN authentication.

Return value

Dictionary

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

cram_md5_auth

cram_md5_auth(user: String, secret: String) -> Dictionary

Package CRAM-MD5 credentials for a verified SMTP session.

Parameters

NameTypeDefaultDescription
userStringRequiredSMTP authentication user name.
secretStringRequiredInput key material used by the derivation operation.

Return value

Dictionary

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

cram_md5

cram_md5(key: PackedByteArray, challenge: PackedByteArray) -> String, Err

Compute the HMAC-MD5 response required by the CRAM-MD5 SMTP mechanism.

Parameters

NameTypeDefaultDescription
keyPackedByteArrayRequiredKey used to select, store or authenticate the corresponding value.
challengePackedByteArrayRequiredDecoded server challenge bytes for CRAM-MD5.

Return value

String, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

dial_smtp

dial_smtp(host: String, port: int, opts: Dictionary = {  }) -> GDSMTPClient, Err

Open a reusable SMTP session without blocking the caller.

Parameters

NameTypeDefaultDescription
hostStringRequiredHostname or IP address used for connecting or binding.
portintRequiredNetwork port number. A listening port of zero lets the OS select a port.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.

Return value

GDSMTPClient, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

dial_smtp_async

dial_smtp_async(host: String, port: int, opts: Dictionary = {  }) -> await GDSMTPClient, Err

Open a reusable SMTP session without blocking the caller.

Parameters

NameTypeDefaultDescription
hostStringRequiredHostname or IP address used for connecting or binding.
portintRequiredNetwork port number. A listening port of zero lets the OS select a port.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.

Return value

await GDSMTPClient, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

send_mail

send_mail(host: String, port: int, from: String, to: PackedStringArray, message: PackedByteArray, opts: Dictionary = {  }) -> Variant, Err

Send one complete message through a reusable SMTP session.

Parameters

NameTypeDefaultDescription
hostStringRequiredHostname or IP address used for connecting or binding.
portintRequiredNetwork port number. A listening port of zero lets the OS select a port.
fromStringRequiredStarting point used by the operation.
toPackedStringArrayRequiredDestination selected by the operation.
messagePackedByteArrayRequiredComplete message bytes transmitted during the SMTP DATA transaction.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.

Return value

Variant, Err

Suspends only the calling routine until the operation completes. No explicit await is needed.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

send_mail_async

send_mail_async(host: String, port: int, from: String, to: PackedStringArray, message: PackedByteArray, opts: Dictionary = {  }) -> await Variant, Err

Send one complete message through a reusable SMTP session.

Parameters

NameTypeDefaultDescription
hostStringRequiredHostname or IP address used for connecting or binding.
portintRequiredNetwork port number. A listening port of zero lets the OS select a port.
fromStringRequiredStarting point used by the operation.
toPackedStringArrayRequiredDestination selected by the operation.
messagePackedByteArrayRequiredComplete message bytes transmitted during the SMTP DATA transaction.
optsDictionary{ }Named options for this operation. Omitted entries use their documented defaults.

Return value

await Variant, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.