> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/emails/templates/test-send.md).

# Send a test

Send yourself a test of an email template before a campaign or trigger uses it.

**Where:** Email → Templates → a template → **Test** · `/projects/<project>/emails/templates/<templateId>/edit`

A test send is a small campaign to you, the signed-in account user, so you can see the template in a real mailbox (or in the message log) with the token values you choose.

## Before you start

* A saved template with no unsaved changes — **Test** is hidden while the form has changes. See [Create or edit a template](/codemash/cloud/emails/templates/editor.md).
* An enabled email integration. With none, the panel says **No email integrations found** and has no **Send** button. Through the Fake **Test Me** nothing leaves Norbix; through a real provider it is a real email.
* Permission `email:create` (the test is a campaign).

## Steps

1. Open the template and press **Test**. The panel **Send Test Email** opens on the right; it closes only with its **X** or **Cancel**.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-b2eac4f11b86e26b9fc6bfbfef5dd7c1d8c0030d%2Ftemplates-test-send-1.png?alt=media" alt="Send Test Email panel: Select language English, Email Provider Test Me (Fake), Test Tokens Panel with Trigger Type and three empty token inputs, a yellow list of missing tokens"><figcaption><p>The test panel before the tokens are filled.</p></figcaption></figure>
2. Fill the panel:

   | Field           | Required | What it does                                                                                  | Example                                                                                                                                  |
   | --------------- | -------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
   | Select language | yes      | The translation to send; the list shows the project languages.                                | `English en`                                                                                                                             |
   | Email Provider  | yes      | The integration that sends the test. The project default is pre-selected.                     | `Test Me (Fake)`                                                                                                                         |
   | Trigger Type    | no       | Lets you fill the tokens a trigger would bring (Database, Membership, File, Payment trigger). | Not a trigger                                                                                                                            |
   | Template Tokens | yes      | A value for every token of the subject and body.                                              | `Recipient.FirstName` = `Ada`, `Email.SignatureId` = `emlsgn_2zT7jxLqeylWMYCPLzDSpm`, `Email.FooterId` = `emlftr_3xxahehZsa7l8kj90ytaxX` |

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-1fe0fa9e37147a880d10168073773e701363ce2b%2Ftemplates-test-send-2.png?alt=media" alt="Template Tokens filled with Ada, a signature id and a footer id; Sends test email to; Cancel and Send buttons"><figcaption><p>Every token has a value; <strong>Send</strong> is on.</p></figcaption></figure>
3. Press **Send**.

## Result

A green toast says **Success!** "Notification sent successfully. See campaigns for more details." The test appears in **Email → Campaigns** as a campaign with the strategy **Account owner or team members**, and its [message log](/codemash/cloud/emails/campaigns/log.md) shows the rendered email.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-7e153ad13d3e7d10fc02042c1c855d2a32813adc%2Ftemplates-test-send-3.png?alt=media" alt="Success toast: Notification sent successfully. See campaigns for more details."><figcaption><p>The test was sent.</p></figcaption></figure>

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-de56777e194e18d980947fb2e11fe9db593ee250%2Fenable-2.png?alt=media" alt="Email Campaigns list with the test on top: Completed, Account owner or team members, Welcome email, Test Me (Default)"><figcaption><p>The test send in the campaigns list.</p></figcaption></figure>

{% hint style="info" %}
The line **Sends test email to:** should show your own address. On the stack used for these pictures it stayed empty, although the test went to the signed-in account user.
{% endhint %}

The test is a campaign, so the campaign checks apply: the language must be a project language and the template needs a translation for every project language.

## Change or remove it later

A test send is an ordinary campaign: open it from **Email → Campaigns** and use **Actions → Delete campaign...** to remove it — see [Campaign details](/codemash/cloud/emails/campaigns/details.md).

## Do it from code

There is no separate test call: send a campaign to your own address. This one went through an SMTP integration to a local mail catcher:

```ts
const { id } = await norbix.hub.notifications.createEmailCampaign({
  campaign: {
    source: 'Email',
    templateId: 'tmpl_3pLex0vXrqcLzOsJP8VLRx',
    integrationId: 'int_7bl0e6pSQmGzNFLp2P6rcd', // Mailpit (local test), SMTP
    recipients: ['ada.lovelace@example.com'],
    mappedTokens: [
      { key: 'Recipient.FirstName', value: 'Ada', resolver: 'Custom' },
      { key: 'Email.SignatureId', value: 'emlsgn_2zT7jxLqeylWMYCPLzDSpm', resolver: 'Custom' },
      { key: 'Email.FooterId', value: 'emlftr_3xxahehZsa7l8kj90ytaxX', resolver: 'Custom' },
    ],
  },
});
// a few seconds later: status 'Completed'
```

```sh
norbix hub notifications email template available tokens get --id tmpl_3pLex0vXrqcLzOsJP8VLRx
```

The CLI line lists the tokens the template needs a value for.

API: [Create Email Campaign](/codemash/api-reference/notifications/email/create-email-campaign.md) · [Get Email Template Available Tokens](/codemash/api-reference/notifications/email/get-email-template-available-tokens.md) · [Preview Email Notification](/codemash/api-reference/notifications/email/preview-email-notification.md)
