Optional integration with jobs module for async email sending.
This namespace provides async email sending via the jobs module. The jobs module is an OPTIONAL dependency - add it to your deps.edn:
{:deps {org.boundary-app/boundary-jobs {:mvn/version "0.1.0"}}}
If jobs module is not available, async functions will throw descriptive errors with :type :missing-dependency.
Usage: ;; Queue email for async sending (queue-email-job! job-queue email-sender prepared-email)
;; Register email job handler with jobs module (register-email-job-handler! job-registry)
The job handler will:
Optional integration with jobs module for async email sending.
This namespace provides async email sending via the jobs module.
The jobs module is an OPTIONAL dependency - add it to your deps.edn:
{:deps {org.boundary-app/boundary-jobs {:mvn/version "0.1.0"}}}
If jobs module is not available, async functions will throw descriptive errors
with :type :missing-dependency.
Usage:
;; Queue email for async sending
(queue-email-job! job-queue email-sender prepared-email)
;; Register email job handler with jobs module
(register-email-job-handler! job-registry)
The job handler will:
- Create a new SMTP sender from config stored in job args
- Send the email using that sender
- Return job result map with :success? and :result or :error(process-email-job job-args)Job handler for sending emails.
This function is registered with the jobs module to process email sending jobs. It receives job args containing the email and SMTP sender configuration, creates a sender instance, and sends the email.
Job args structure: :email - Email map (from prepare-email) with: :id - UUID :to - Vector of recipient addresses :from - Sender address :subject - Email subject :body - Email body (plain text) :headers - Optional headers map :sender-config - SMTP sender configuration with: :host - SMTP server host :port - SMTP server port :username - SMTP auth username (optional) :password - SMTP auth password (optional) :tls? - Enable STARTTLS :ssl? - Enable SSL
Returns: Job result map with: :success? - Boolean indicating success/failure :result - Result data (if successful) with: :email-id - Email UUID :message-id - Message ID from SMTP provider :sent-at - Instant when sent :error - Error map (if failed) with: :message - Error message :type - Error type :stacktrace - Stack trace string
Example successful result: {:success? true :result {:email-id #uuid "..." :message-id "msg-123@smtp.example.com" :sent-at #inst "2026-01-27T10:30:00Z"}}
Example error result: {:success? false :error {:message "Connection timeout" :type "SmtpError" :stacktrace "..."}}
Job handler for sending emails.
This function is registered with the jobs module to process email sending jobs.
It receives job args containing the email and SMTP sender configuration,
creates a sender instance, and sends the email.
Job args structure:
:email - Email map (from prepare-email) with:
:id - UUID
:to - Vector of recipient addresses
:from - Sender address
:subject - Email subject
:body - Email body (plain text)
:headers - Optional headers map
:sender-config - SMTP sender configuration with:
:host - SMTP server host
:port - SMTP server port
:username - SMTP auth username (optional)
:password - SMTP auth password (optional)
:tls? - Enable STARTTLS
:ssl? - Enable SSL
Returns:
Job result map with:
:success? - Boolean indicating success/failure
:result - Result data (if successful) with:
:email-id - Email UUID
:message-id - Message ID from SMTP provider
:sent-at - Instant when sent
:error - Error map (if failed) with:
:message - Error message
:type - Error type
:stacktrace - Stack trace string
Example successful result:
{:success? true
:result {:email-id #uuid "..."
:message-id "<msg-123@smtp.example.com>"
:sent-at #inst "2026-01-27T10:30:00Z"}}
Example error result:
{:success? false
:error {:message "Connection timeout"
:type "SmtpError"
:stacktrace "..."}}(queue-email-job! job-queue email-sender email)Queue email for async sending via jobs module.
This function enqueues an email sending job to be processed asynchronously by the jobs module worker pool.
Args: job-queue - IJobQueue instance from jobs module email-sender - SmtpEmailSender instance (used to extract config) email - Email map (from prepare-email) with: :id - UUID :to - Vector of recipient addresses :from - Sender address :subject - Email subject :body - Email body (plain text) :headers - Optional headers map
Returns: Job ID (UUID) from jobs module
Throws: ex-info with :type :missing-dependency if jobs module not available
Requires: Jobs module must be added to deps.edn: {:deps {org.boundary-app/boundary-jobs {:mvn/version "0.1.0"}}}
Queue email for async sending via jobs module.
This function enqueues an email sending job to be processed asynchronously
by the jobs module worker pool.
Args:
job-queue - IJobQueue instance from jobs module
email-sender - SmtpEmailSender instance (used to extract config)
email - Email map (from prepare-email) with:
:id - UUID
:to - Vector of recipient addresses
:from - Sender address
:subject - Email subject
:body - Email body (plain text)
:headers - Optional headers map
Returns:
Job ID (UUID) from jobs module
Throws:
ex-info with :type :missing-dependency if jobs module not available
Requires:
Jobs module must be added to deps.edn:
{:deps {org.boundary-app/boundary-jobs {:mvn/version \"0.1.0\"}}}(register-email-job-handler! job-registry)Register email job handler with jobs module.
This function registers the :send-email job type with the jobs module's job registry. After registration, jobs with :job-type :send-email will be processed by the process-email-job handler.
Args: job-registry - IJobRegistry instance from jobs module
Returns: :send-email (the job type keyword)
Throws: ex-info with :type :missing-dependency if jobs module not available
Usage: (def job-registry (create-job-registry)) (register-email-job-handler! job-registry) ;; Now email jobs can be processed
Requires: Jobs module must be added to deps.edn: {:deps {org.boundary-app/boundary-jobs {:mvn/version "0.1.0"}}}
Register email job handler with jobs module.
This function registers the :send-email job type with the jobs module's
job registry. After registration, jobs with :job-type :send-email will
be processed by the process-email-job handler.
Args:
job-registry - IJobRegistry instance from jobs module
Returns:
:send-email (the job type keyword)
Throws:
ex-info with :type :missing-dependency if jobs module not available
Usage:
(def job-registry (create-job-registry))
(register-email-job-handler! job-registry)
;; Now email jobs can be processed
Requires:
Jobs module must be added to deps.edn:
{:deps {org.boundary-app/boundary-jobs {:mvn/version \"0.1.0\"}}}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |