Skip to content

Mail

Overview

Module

SMTP delivery entry point. getInstance() returns the platform-configured MailClient (host, port, credentials picked up from DIRIGIBLE_MAIL_* config); the Properties-accepting overload lets you override settings per call for one-off messages or multi-tenant fan-out.

Each send accepts a list of Map parts — one per MIME body — that the underlying client packs into a multipart/mixed or multipart/alternative structure. Use a text/plain and text/html pair for typical transactional mail.

Key Features:

  • Platform-default client — picks up DIRIGIBLE_MAIL_* configuration automatically.
  • Per-call overridesgetInstance(properties) supports multi-tenant fan-out.
  • MIME parts via Map — consistent JSON-shaped parts across the platform.

Example Usage:

java
import org.eclipse.dirigible.sdk.mail.Mail;
import java.util.List;
import java.util.Map;

Map result = Mail.send(
    "noreply@acme.com",
    new String[] { "alice@acme.com" },
    null,
    null,
    "Your invoice",
    List.of(
        Map.of("type", "text", "subType", "plain", "content", "Invoice attached."),
        Map.of("type", "text", "subType", "html",  "content", "<p>Invoice attached.</p>")
    )
);

Methods

getInstance()

Returns the platform-configured mail client.

java
public static MailClient getInstance();

Returns

  • Type: MailClient
  • Description: The default mail client wired from DIRIGIBLE_MAIL_* config.

getInstance() — properties override

Returns a mail client built from the supplied Properties, allowing per-call overrides of host, port, credentials, and other JavaMail settings.

java
public static MailClient getInstance(Properties properties);
ParameterTypeDescription
propertiesPropertiesJavaMail properties to override the defaults.

Returns

  • Type: MailClient
  • Description: A mail client backed by the supplied properties.

send()

Sends a multipart message via the default mail client.

java
public static Map send(String from, String[] to, String[] cc, String[] bcc, String subject, List<Map> parts)
    throws MessagingException;
ParameterTypeDescription
fromStringSender address.
toString[]Primary recipients.
ccString[]Carbon-copy recipients (may be null).
bccString[]Blind-carbon-copy recipients (may be null).
subjectStringMail subject.
partsList<Map>One Map per MIME part — keys typically type, subType, content.

Returns

  • Type: Map
  • Description: Result map from the underlying client (e.g. message id). |

Released under the EPL-2.0 License.