Package com.onec.mail
Class MailService
java.lang.Object
com.onec.mail.MailService
High-level mail facade. Three modes of use:
send(MailMessage)- synchronous dispatch via the active provider.queue(MailMessage)- durable queue via the mail outbox; relayed asynchronously with retry.send(Object, String, String...)- render a registeredMailTemplatebound totarget.getClass()and dispatch (queued or direct based on config).
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 Summary
ConstructorsConstructorDescriptionMailService(MailDispatcher dispatcher, MailTemplateRegistry templates, MailRenderer renderer, MailProperties properties, MailOutbox outbox, MailSuppressionList suppressionList, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionqueue(MailMessage message) Durable queue.queue(MailMessage message, String idempotencyKey) Durable queue with an idempotency key: enqueuing twice with the same key dispatches once.queue(Object target, String templateName, String idempotencyKey, Map<String, Object> extras, String... recipients) voidsend(MailMessage message) Synchronous dispatch via the configured provider.voidvoidRender a template registered againsttarget.getClass()and dispatch.
-
Constructor Details
-
MailService
public MailService(MailDispatcher dispatcher, MailTemplateRegistry templates, MailRenderer renderer, MailProperties properties, MailOutbox outbox, MailSuppressionList suppressionList, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
send
Synchronous dispatch via the configured provider. Suppressed recipients are removed first. -
queue
Durable queue. Picked up by the relay and dispatched asynchronously with retry/backoff. -
queue
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 againsttarget.getClass()and dispatch. -
send
-
queue
-
queue
-