PhoenixKit.Users.WelcomeEmailWorker (phoenix_kit v2.55.1)

Copy Markdown View Source

Sends one user's welcome email, after the confirmation that enqueued it has committed. See PhoenixKit.Users.WelcomeEmail.

Job args

%{"user_uuid" => "<uuid>"}

What a run does

  1. Nothing, when the welcome email has been switched off since, or the user is gone. A deactivated user (is_active false) gets nothing either, with a line in the log.
  2. Claims the account: one conditional UPDATE writes welcome_email_sent_at into custom_fields only where it is absent and the address is confirmed. No row updated means it was sent already, or the address is no longer confirmed — done.
  3. Builds the message, then hands it to the mailer.

At most once

The mark is cleared — and the job retried — only when the message is known not to have gone out: building it failed (rendering, a template, the provider; raised, thrown or exited), or the mailer reported that it was not sent ({:error, reason}). A raise or exit during delivery leaves it unknown whether the message went out, so the mark stays, the error is logged and the job is cancelled rather than retried. So is a node that dies between the claim and the send: that welcome email is lost. Both are deliberate — a missing welcome email is a smaller harm than a second one.