Interface MailDelivery


public interface MailDelivery

郵件遞送 SPI(EMAIL 通道的應用層接縫)

框架的 EmailNotificationChannel 不直接持有寄信能力——它委派此介面實際寄出。如此把 租戶郵件設定(寄件帳號、SMTP / OAuth2 認證、per-tenant MailSetting 等)留在應用層, 框架保持中性:應用層以租戶感知的寄信服務實作 send,通道層只負責「把渲染好的內容交出去」。

遞送失敗以拋例外表達(由 EmailNotificationChannel 轉為 DeliveryResult.failed(String) 並觸發重試)。呼叫時當前 TenantContext 已由 dispatcher 依 Outbox 列重建, 實作可直接解析當前租戶的郵件設定。

Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    send(EmailEnvelope envelope)
    寄出一封含完整 To / CC 關係的 HTML 郵件。
    void
    send(String to, String subject, String htmlBody)
    寄出一封 HTML 郵件(以當前租戶郵件設定)
  • Method Details

    • send

      void send(String to, String subject, String htmlBody)
      寄出一封 HTML 郵件(以當前租戶郵件設定)
      Parameters:
      to - 收件人位址
      subject - 主旨
      htmlBody - HTML 內文
      Throws:
      RuntimeException - 遞送失敗(由通道層轉為失敗結果並重試)
    • send

      default void send(EmailEnvelope envelope)

      寄出一封含完整 To / CC 關係的 HTML 郵件。

      舊實作者在沒有 CC 時仍可沿用三參數 send(String, String, String);收到 CC 而尚未 實作本方法時明確失敗,避免靜默漏寄副本。需要 CC 的應用 adapter 應覆寫本方法。 支援 provider idempotency 的 adapter 應把 EmailEnvelope.deliveryId 原樣傳給 provider; 不得由郵件內容、收件人或業務識別自行重建。

      Parameters:
      envelope - 郵件信封與內容
      Throws:
      RuntimeException - 遞送失敗,或舊實作者尚未支援 CC