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.mimeParse and format MIME media types, encoded words, quoted-printable bytes, and multipart bodies.
Methods
parse_address(text: String) -> Dictionary, Errparse_address_list(text: String) -> Array, Errparse_date(text: String) -> Dictionary, Errread_message(data: PackedByteArray) -> GDMailMessage, Errread_message_async(source: Variant) -> await GDMailMessage, Errplain_auth(user: String, password: String, identity: String = "") -> Dictionarycram_md5_auth(user: String, secret: String) -> Dictionarycram_md5(key: PackedByteArray, challenge: PackedByteArray) -> String, Errdial_smtp(host: String, port: int, opts: Dictionary = { }) -> GDSMTPClient, Errdial_smtp_async(host: String, port: int, opts: Dictionary = { }) -> await GDSMTPClient, Errsend_mail(host: String, port: int, from: String, to: PackedStringArray, message: PackedByteArray, opts: Dictionary = { }) -> Variant, Errsend_mail_async(host: String, port: int, from: String, to: PackedStringArray, message: PackedByteArray, opts: Dictionary = { }) -> await Variant, Err
parse_address
parse_address(text: String) -> Dictionary, ErrParse one display name and mailbox.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text 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, ErrParse comma-separated mailboxes without discarding display names.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text 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, ErrParse a mail date while retaining its numeric timezone offset.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text 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, ErrSplit a mail message into repeated headers and its untouched body bytes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
data | PackedByteArray | Required | Input 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, ErrParse headers from bytes or a readable stream without collecting the whole body.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source | Variant | Required | Message 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 = "") -> DictionaryPackage PLAIN credentials for a verified SMTP session.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
user | String | Required | SMTP authentication user name. |
password | String | Required | Password bytes used as key-derivation input. |
identity | String | "" | 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) -> DictionaryPackage CRAM-MD5 credentials for a verified SMTP session.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
user | String | Required | SMTP authentication user name. |
secret | String | Required | Input 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, ErrCompute the HMAC-MD5 response required by the CRAM-MD5 SMTP mechanism.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
key | PackedByteArray | Required | Key used to select, store or authenticate the corresponding value. |
challenge | PackedByteArray | Required | Decoded 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, ErrOpen a reusable SMTP session without blocking the caller.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
opts | Dictionary | { } | 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, ErrOpen a reusable SMTP session without blocking the caller.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
opts | Dictionary | { } | 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, ErrSend one complete message through a reusable SMTP session.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
from | String | Required | Starting point used by the operation. |
to | PackedStringArray | Required | Destination selected by the operation. |
message | PackedByteArray | Required | Complete message bytes transmitted during the SMTP DATA transaction. |
opts | Dictionary | { } | 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, ErrSend one complete message through a reusable SMTP session.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
host | String | Required | Hostname or IP address used for connecting or binding. |
port | int | Required | Network port number. A listening port of zero lets the OS select a port. |
from | String | Required | Starting point used by the operation. |
to | PackedStringArray | Required | Destination selected by the operation. |
message | PackedByteArray | Required | Complete message bytes transmitted during the SMTP DATA transaction. |
opts | Dictionary | { } | 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.