add()

Send an email.

Syntax

add(email Object)

Add an email to the outbox.

Parameters

email Object

Email data.

Object keys:

  • to string. Optional. Comma separated list of recipients. When not specified, emails are sent to the project owner.
  • cc string. Optional. Comma separated list of CC recipients.
  • bcc string. Optional. Comma separated list of BCC recipients.
  • subject string. Email subject.
  • textBody string?. Optional. Text alternative of the email body.
  • htmlBody string?. Optional. Html alternative of the email body.

Description

Send an email by adding it to the outbox. The outbox is attached to the transaction and will be dropped if the transaction fails. If the transaction succeeds and it was a nested transaction, it is passed up along the chain. Once the root transaction successfully finishes, emails in its outbox are queued for sending.

Parent transactions have the ability to prevent sending the email. This aids testing.

Examples

Add a text email to the outbox, to be sent to the specified recipient.

Add a text email to the outbox, to be sent to the project owner.

Add a html email to the outbox.

Add an email to the outbox with both html and text variants.

Provide to, cc, bcc.

Including both the recipient name and email address.

Send email to multiple recipients.