Sending emails from Gosu code

To send an email from Gosu, you need to do the following:

  • First, create the email, typically through the use of email templates.
  • Send the email using one of the gw.api.email.EmailUtil.sendEmailWithBody methods.

Transaction bundle commits

It is possible to send an email either from a Gosu rule or directly from Gosu code. Which method you use affects whether you need to commit the email transaction.
Rule execution If you create and send an email as part of rule workflow, you do not need to commit the email transaction as it is already part of the rule transaction commit. Creating an email message and storing it in the Send Queue occurs as part of the same database transaction in which the rules run. This is the same as regular message creations triggered through rules.
Gosu execution If you create and send an email directly from Gosu code, outside of a Gosu rule, it is more likely that you need to commit the email transaction, depending on the exact circumstances of your Gosu code.