> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Vindicia Subscribe Email Templates

Vindicia Subscribe can automatically issue customer email notifications for predefined events in a billing cycle, such as an upcoming billing, an overdue payment, or other relevant event.

In order for Vindicia Subscribe to issue an email notification, you must first provide Vindicia with a customized email template for the particular event type. An email template includes a combination of the general message content (the greeting and so on) in HTML format, and email tags which are replaced by data from Vindicia Subscribe when the email is generated.

Vindicia Subscribe generates an email when a trigger event occurs. You must designate the events which trigger an email notification, such as a successful call to AutoBill.update, Transaction.authCapture, or Refund.perform. For more information about the billing and invoicing events which can trigger email notifications, see [Working with Customer Notifications](https://docs.vindicia.com/bundle/SOAP-Programming-guide/page/topics/ProgGuide_CustomerNotifications.html) in the **Vindicia Subscribe SOAP API Programming Guide**.

**Note:**

Vindicia Subscribe does not issue default emails. If a trigger event occurs but you have not provided a template for it, Vindicia Subscribe does not issue an email. (However, the trigger event is recorded in the SOAP log for troubleshooting purposes.)

## The Email Template Uploading Process

To upload email templates, you must provide the templates to Vindicia. You cannot directly upload email templates into Vindicia Subscribe.

To upload email templates:

1. Create a set of email templates that incorporate email tags supported by Vindicia Subscribe and provide them to Vindicia.
2. Vindicia loads the templates into the database in Staging for testing by your organization.
3. The load/test process repeats until the templates have passed your QA.
4. When the email templates are ready to launch, Vindica loads the template into Production.
5. If you need to make changes to the templates after they are in live production, open a support ticket and give the updated templates to Vindicia Client Technical Support (CTS.)

## Email Tags: Tuples vs. Template Toolkit

Vindicia Subscribe supports two syntax forms to embed email tags into your email content:

* A tuple is an ordered set of values. Tuples are simplistic devices that allow only for the replacement of the single data element the tag represents, such as “amount”, “name”, and so on.
* Template Toolkit is a set of open-source Perl modules (not developed by Vindicia) which can be used to employ programmatic constructs around email tags. For example, an array of transaction items can be iterated through and tested for specific values using statements such as FOREACH and IF, and regular expression matching such as “==” and “!=”.

  For more information about Template Toolkit, see [http://template-toolkit.org/](http://template-toolkit.org/).

You must use either the tuple structure *or* the Template Toolkit structure in an email template. You cannot use both in the same template.

**Note:**

Not all email tags available in Vindicia Subscribe are populated for every event. For example, there is a tag for “refund\_amount” which is blank for every template except the Refund email template.

## Using Tuples

Tuples take the form `<tpl name="<TAG>"/>`. As an example, the tuple for the amount tag is `<tpl name="amount"/>`, which is replaced with the actual amount generated on a Transaction by Vindicia Subscribe when this email event is triggered.

For information about tuples available in Vindicia Subscribe, see [Creating Billing Notification Templates](https://docs.vindicia.com/bundle/SOAP-Programming-guide/page/topics/Creating_Billing_Notific.html) in the **Vindicia Subscribe Programming Guide**.

## Using Template Toolkit

Template Toolkit support in Vindicia Subscribe is a method of enveloping the available email tags within the Template Toolkit structure. Some email tags in Vindicia Subscribe can be in the form of an array, which can be unwieldy for the simple tuple structure. For example, in a Transaction with more than one Transaction Item (`sku`), there are several arrays that can be used together to display a coherent picture of the transaction: `sku`, `price`, and `desc`.

The following Template Toolkit example iterates through these tag arrays in order to display the correct amount of purchased items in an email, skipping any items that do not have a value for `price`:

```

[% idx = 0 %]
[% FOREACH p IN price -%]
            [% IF price.$idx != '' -%]
                [% desc.$idx %] (SKU [% sku.$idx %]): [% price.$idx %]
            [% END -%]
                [% idx = idx + 1 %]
[% END -%]

```

The following example uses the `affiliate` tag to change the text in the greeting:

```

[% IF merchant_affiliate == '' -%]
Thank you for being a loyal customer of MyDefaultMerchant.com!
[% ELSE -%]
Thank you for being a loyal customer of [% merchant_affiliate %].com!
[% END -%]
```

## Testing Template Toolkit

When using Template Toolkit, it is useful to test the syntax locally without loading email templates and trigger events. To test syntax, download the Template Toolkit modules and use the tpage tool. Download Template Toolkit modules at [http://template-toolkit.org/](http://template-toolkit.org/)

The example below uses tpage to test a text template with some tag parameters defined on the command line and some defined in the input file:

1. The test file test.tt contains the following content:

   ```

   [%
   'price' => {
   '0' => '5.00',
   '1' => '3.50',
   '2' => '2.75',
   '3' => '',
   }
   %]
   [%
   'desc' => {
   '0' => 'Annual Membership Fee',
   '1' => 'Field Fee',
   '2' => 'Equipment Fee',
   '3' => 'Optional Premium Member Fee',
   }
   %]
   [%
   'sku' => {
   '0' => 'AMF2017',
   '1' => 'FF2017',
   '2' => 'EF2017',
   '3' => 'OPMF2017',
   }
   %]
   Dear [% name %],
   On [% expirationdate %], your LittleLeague Membership is scheduled for renewal.
   LittleLeague will bill $[% grand_total %] to your [% cctype %] for a [% interval %] extension.
   Fees included in your total price:
   [% idx = 0 %]
   [% FOREACH p IN price -%]
   [% IF price.$idx != '' -%]
   [% desc.$idx %] (SKU [% sku.$idx %]): [% price.$idx %]
   [% END -%]
   [% idx = idx + 1 %]
   [% END -%]
   If you prefer not to be billed automatically for renewal, you may disable this option on the membership section of your profile page:
   https://accounts.littleleague.com/account/membership
   Thanks again for being a part of the extraordinary LittleLeague community!
   If you have any questions please visit our support center at:
   https://support.littleleague.com
   Membership Terms of Service:
   https://accounts.littleleague.com/me...rms_of_service
   Sincerely,
   The LittleLeague Membership Team

   ```

2. The command line shown here specifies the data to replace the tags in the test file:

   ```

   tpage --define name='John Q. Public' --define grand_total=11.25 --define cctype=Visa --define interval='1 year' --define expirationdate='09/30/2016' test.tt

   ```

3. The test generates the following email:

   ```
   Dear John Q. Public, 
   On 09/30/2016, your LittleLeague Membership is scheduled for renewal. 
   LittleLeague will bill $11.25 to your Visa for a 1 year extension. 
   Fees included in your total price: 
   Annual Membership Fee (SKU AMF2017): 5.00 
   Field Fee (SKU FF2017): 3.50 
   Equipment Fee (SKU EF2017): 2.75 
   If you prefer not to be billed automatically for renewal, you may disable 
   this option on the membership section of your profile page: 
   [https://accounts.littleleague.com/account/membership](https://accounts.littleleague.com/account/membership) 
   Thanks again for being a part of the extraordinary LittleLeague community! 
   If you have any questions please visit our support center at: 
   [https://support.littleleague.com/](https://support.littleleague.com/) 
   Membership Terms of Service: 
   [https://accounts.littleleague.com/me...rms\_of\_service](https://accounts.littleleague.com/me...rms_of_service) 
   Sincerely, 
   The LittleLeague Membership Team
   ```

## Sample Email Templates using Template Toolkit

The following email template examples represent typical customer notifications.

## Pre-Billing (No Payment Method on File)

```

* Subject:
Your LittleLeague Membership is about to Expire
* Body:
Dear [ % name % ],
We hope you are enjoying your LittleLeague Membership. Your Membership benefits are set to expire on
[ % expirationdate % ]. If you want to avoid a lapse in benefits you should add a payment method
to your Membership benefits page:
https://accounts.littleleague.com/account/membership
If a payment method is added you will be billed [ % price % ] on [ % date % ]. You may
change your renewal preferences and billing information on your Membership benefits page:
https://accounts.littleleague.com/account/membership
If you have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
The LittleLeague Membership Team

```

## Pre-Billing (Payment Method on File)

```

* Subject:
LittleLeague Membership: Upcoming Billing
* Body:
Dear [ % name % ],
On [ % expirationdate % ], your LittleLeague Membership is scheduled for renewal;
LittleLeague will bill [ % grand_total % ] to your [ % payment_type % ] for
a [ % interval % ] extension.
If you prefer not to be billed automatically for renewal, you may disable this
option on the membership section of your profile page:
https://accounts.littleleague.com/account/membership
Thanks again for being a part of the extraordinary LittleLeague community!
If you have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Success on Initial Subscription

```

* Subject:
LittleLeague Membership: Billing Confirmation
* Body:
Dear [ % name % ],
On [ % date % ], we billed your [ % payment_type % ]
[ % grand_total % ] for [ % interval % ] of your LittleLeague
League Membership. Your next renewal date will be [ % nextdate % ].
You may set your renewal preferences at any time on the membership section of
your profile page:
https://accounts.littleleague.com/account/membership
Thanks again for being a part of the extraordinary LittleLeague community!
If you have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Success on Subscription Renewal

```

* Subject:
LittleLeague Membership: Billing Confirmation
* Body:
Dear [ % name % ],
On [ % date % ], we billed your [ % payment_type % ]
[ % grand_total % ] for a [ % interval % ] renewal of your LittleLeague
League Membership. Your next renewal date will be [ % nextdate % ].
You may set your renewal preferences at any time on the membership section of
your profile page:
https://accounts.littleleague.com/account/membership
Thanks again for being a part of the extraordinary LittleLeague community!
If you have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Hard Fail On Subscription Renewal

```

* Subject:
LittleLeague Membership: Billing Failure, Attention Required
* Body:
Dear [ % name % ],
On [ % date % ], we attempted to charge [ % grand_total % ] to
your [ % payment_type % ] to renew your LittleLeague Membership for
[ % interval % ]. However, the charge was unfortunately declined.
On [ % expirationdate % ], your LittleLeague account will be switched to free
non-LittleLeague status. To regain your status an LittleLeague Member, you may
edit your billing information on your Membership Profile page:
https://accounts.littleleague.com/account/membership
We hope you will continue to be a part of the extraordinary LittleLeague community! If you
have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Subscription Expiration

```

* Subject:
LittleLeague Membership Expiration
* Body:
Dear [ % name % ],
On [ % expirationdate % ], your LittleLeague Membership will expire. On
that date, your LittleLeague account will be switched to free non-LittleLeague Member status. To
maintain your status an LittleLeague Member, you may purchase an LittleLeague
Membership from the LittleLeague Store:
http://store.littleleague.com/t/cate...gue-membership
We hope you'll continue to be a part of the extraordinary LittleLeague community! If you have
any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Subscription Cancellation

```

* Subject:
LittleLeague Membership Cancellation
* Body:
Dear [ % name % ],
Your request to cancel your LittleLeague Membership has been recieved. On [ % expirationdate % ]
your LittleLeague account will be switched to free non-LittleLeague Member status. To maintain
your status an LittleLeague Member, you may purchase an LittleLeague Membership from the LittleLeague Store:
http://store.littleleague.com/t/cate...gue-membership
We are sorry to see you go and hope you have enjoyed your time as an LittleLeague Member with
great benefits like ad-free, high quality live streams - including
2 additional Starcraft 2 streams, first access to VOD footage, members-only
tournaments, discounts and much more!
If you believe this action has been made in error, please contact LittleLeague Support:
http://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Refund

```

* Subject:
LittleLeague Membership Refund
* Body:
Dear [ % name % ],
A refund of [ % grand_total % ] has been applied to your
[ % payment_type % ] for the remaining time left on your LittleLeague
Membership, and your LittleLeague account has been switched to free non-League Member
status.
We hope you'll continue to be a part of the extraordinary LittleLeague community! If you
have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## End of Trial Event

```

* Subject:
LittleLeague Membership: End of Trial Period
* Body:
Dear [ % name % ],
On [ % expirationdate % ], your LittleLeague Membership trial term will
expire and your LittleLeague account will be switched to free non-League Member status. To
maintain your status an LittleLeague Member, you may purchase an LittleLeague
Membership from the LittleLeague Store:
http://store.littleleague.com/
We hope you'll continue to be a part of the extraordinary LittleLeague community and enjoy
great benefits like ad-free, high quality live streams - including 2 additional
Starcraft 2 streams, first access to VOD footage, members-only tournaments,
discounts and much more!
If you have any questions please visit our support center at
https://support.littleleague.com/
Membership Terms of Service:
https://accounts.littleleague.com/me...rms_of_service
- The LittleLeague Membership Team

```

## Sample Code

Under construction.

**Parent topic:**[Email Notifications](../topics/r_emailNotifications)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.