Package com.onec.mail

Class MailService

java.lang.Object
com.onec.mail.MailService

public class MailService extends Object
High-level mail facade. Three modes of use: Default routing of send(Object, String, String...) is controlled by onec.mail.use-outbox.

Recipients on the MailSuppressionList (hard bounces, complaints, unsubscribes) are dropped before dispatch; a message left with no recipients is skipped entirely.

  • Constructor Details

  • Method Details

    • send

      public void send(MailMessage message)
      Synchronous dispatch via the configured provider. Suppressed recipients are removed first.
    • queue

      public UUID queue(MailMessage message)
      Durable queue. Picked up by the relay and dispatched asynchronously with retry/backoff.
    • queue

      public UUID queue(MailMessage message, String idempotencyKey)
      Durable queue with an idempotency key: enqueuing twice with the same key dispatches once. Use a stable business id (e.g. "booking-confirmed:" + booking.number) to make retries safe.
    • send

      public void send(Object target, String templateName, Map<String,Object> extras, String... recipients)
      Render a template registered against target.getClass() and dispatch.
    • send

      public void send(Object target, String templateName, String... recipients)
    • queue

      public UUID queue(Object target, String templateName, Map<String,Object> extras, String... recipients)
    • queue

      public UUID queue(Object target, String templateName, String idempotencyKey, Map<String,Object> extras, String... recipients)