Skip to end of metadata
Go to start of metadata

The Email Templates screen lets you create and edit plain text and HTML email templates. The email template's subject and body can contain placeholder values that are dynamically replaced with values you specify when sending the email using the Mobile Backend Services (MBS) email_from_template  REST API, Titanium.Cloud.Emails.send() method or equivalent native iOS or Android method. The email can be sent as plain text, HTML, or multi-part using these methods.

Creating an email template

An email template specifies the email subject line and body, which may be HTML or plain-text. You specify the template name when calling email_from_template, the recipients, and values for any placeholder values.

To create an email template:

  1. In Dashboard, select the Mobile Backend Services datasource to create the email template for.
  2. Select Manage Data, then click Email Templates.
  3. Click Create Email Template.
  4. Click the Code tab, and provide values for the following fields:
    1. Name – Name of the email template. You will specify this name when sending the email.
    2. Subject – The email's subject. The subject can contain placeholder values in double curly brackets.
    3. Body (HTML) – The email's HTML-formatted body text. The body can contain placeholder values in double curly brackets.
    4. Body (Plain Text) – The email's plain text-formatted body text. The body can contain placeholder values in double curly brackets.
  5. Click Preview to view a rendered version of the HTML body text.
  6. Click Save Changes.

Below is the sample HTML used in the above screenshot:

Sending email based on a template 

To send an email based on a template, call the  email_from_template MBS method from your own application. For example, the following code example uses the Titanium.Cloud.Emails.send() method to send an email based on the 'welcome_template' to a user.

Using placeholder fields

The template's subject and body can contain placeholder fields delineated by double curly brackets ({{}}). When sending an email, you include a parameter for each placeholder field that specifies the value to insert. For example, suppose that your email template's subject field contains Hi {{first_name}}!. When sending the email you would include a first_name parameter, as shown below:

In a Titanium application, you would simply add the placeholder field as another parameter to the send() method:

  • No labels