1. Home
  2. Docs
  3. General
  4. Customized templates guide
  5. Using Templates in Emails

Using Templates in Emails

After you have created some templates, using them in emails is very simple and can be done either from the Trustifi web portal or using Trustifi’s API.

Using the Web Portal

Open the “New Secure Email” page, enter the email’s recipients, and click on the “Load Template” button to the left of the text editor window (see figure 5).

Finding the “Load Template” button

Figure 5: finding the “Load Template” button


 

After you have clicked on this button, a pop-up window will appear where you can select which template you want to use.

Once a template is selected, simply click on “Load” and the template will be loaded into the text editor (see figure 6).

Loading a template

Figure 6: loading a template

Using the API

Using the API to send an email with a template is very similar to the process of sending a “regular” email – all that needs to be added to the API request is the “template” object which includes the template name and any custom dynamic fields (if there are any).

The documentation for sending an API email with a template can be found here - https://api.trustifi.com/#65118bcc-cf29-4b36-bb8a-b86f7232cb5d

See the example below (this example is using Curl, but many other languages are supported):

curl --location --request POST 'https://be.trustifi.com/api/i/v1/email' \

--header 'x-trustifi-key: {{trustifi_key}}' \

--header 'x-trustifi-secret: {{trustifi_secret}}' \

--header 'Content-Type: application/json' \

--data-raw '{

  "template": {

        "name": "my_template",

        "fields": {

                 "first_field": "hello",

                 "second_field": "world"

        }

  },

  "recipients": [{"email": "test@gmail.com", "name": "test", "phone":{"country_code":"+1","phone_number":"1111111111"}}],

  "lists": [],

  "contacts": [],

  "methods": {

    "postmark": false,

    "secureSend": false,

    "encryptContent": false,

    "secureReply": false

Was this article helpful to you? Yes 1 No

How can we help?