API: client
Source:
mail/client.ts
Provides a client for sending emails, supporting both simple text/HTML messages and complex multipart messages with attachments or inline content.
Usage
import { client } from "sdk/mail";
import { response } from "sdk/http";
const sender = "dirigible@eclipse.org";
const to = "example@gmail.com";
const subject = "Subject";
const content = "<h1>Content<h1>";
const subType = "html";
client.send(sender, to, subject, content, subType);
response.println("Mail sent");Classes
MailClient
The MailClient provides methods for sending emails, handling recipient processing
and interfacing with the underlying MailFacade.
Methods
sendMultipart
sendMultipart (from:string, recipients:string|MailRecipients, subject:string, parts:MailMultipart[]):voidA static convenience method to send a multipart email without instantiating a client.
This is suitable for emails that require attachments, inline images, or mixed content.
@param from The sender's email address.
@param recipients The recipient(s) structure (string for 'to', or {@link MailRecipients} object).
@param subject The subject line of the email.
@param parts An array of {@link MailMultipart} objects defining the email content.
send
send (from:string, recipients:string|MailRecipients, subject:string, text:string, contentType:MailContentType):voidA static convenience method to send a simple email with only a single text or HTML body.
@param from The sender's email address.
@param recipients The recipient(s) structure (string for 'to', or {@link MailRecipients} object).
@param subject The subject line of the email.
@param text The body content of the email.
@param contentType Specifies the body format: 'html' or 'plain'.
send
send (from:string, _recipients:string|MailRecipients, subject:string, text:string, contentType:MailContentType):voidSends a simple email with a single body part (text or HTML).
@param from The sender's email address.
@param _recipients The recipient(s) structure (string for 'to', or {@link MailRecipients} object).
@param subject The subject line of the email.
@param text The body content of the email.
@param contentType Specifies the body format: 'html' or 'plain'.
@throws {Error} Throws an error if the recipient format is invalid or the native call fails.
sendMultipart
sendMultipart (from:string, _recipients:string|MailRecipients, subject:string, parts:MailMultipart[]):voidSends a complex email composed of multiple parts (text bodies, HTML, attachments, inline content).
@param from The sender's email address.
@param _recipients The recipient(s) structure (string for 'to', or {@link MailRecipients} object).
@param subject The subject line of the email.
@param parts An array of {@link MailMultipart} objects defining the email content.
@throws {Error} Throws an error if the recipient format is invalid or the native call fails.