# Common Mailer Examples

*Article Topics:* [*Emails*](/getting-started/common-topics/emails.md)

This page is here to give you a list of common mailers that are done through NATS.

{% hint style="info" %}
**Good to Know:** Even when copying these examples you should ALWAYS run test e-mails to make sure your e-mail is sent out properly.
{% endhint %}

## Latest FHG

### Template Functions Used

* [Nats\_encode](/nats-admin/skins-and-templates/further-reading/template-functions/nats_encode.md)
* [Nats\_display\_adtools](/nats-admin/skins-and-templates/further-reading/template-functions/nats_display_adtools.md)
* [list\_sites](/nats-admin/skins-and-templates/further-reading/template-functions/nats_list_sites.md)
* [list\_programs](/nats-admin/skins-and-templates/further-reading/template-functions/nats_list_programs.md)

### Code Example

{% code overflow="wrap" %}

```
{list_sites} 
{foreach from=$sites key=site_id item=site_name}
    <b>5 Latest FHG for {$site_name}:</b><br />
    {display_adtools data_only=1 order="published_date DESC" count=5 category=2 typeid=2 siteid=$site_id programid=1}     
    {foreach from=$adtools key=adtool_id item=adtool_data}
        {nats_encode siteid=$site_id programid=1 userid=$toid adtoolid=$adtool_data.adtoolid url=1}
	<a href="{$encoded}">{$adtool_data.name}</a><br />
	<b>{$adtool_data.description}</b><br />
    {/foreach}
    <br /><br />
{/foreach}
```

{% endcode %}

* "{list\_sites}" - is creating an array with sites that are \*not\* hidden
* "{foreach from=$sites key=site\_id item=site\_name}" - will loop through every site defining a variable for both its id(key) and name(item)
* "5 Latest FHG for {$site\_name}": - will display the text "5 Latest FHG for " and then your current site name
* "{display\_adtools data\_only=1 order="published\_date DESC" count=5 category=2 typeid=2 siteid=$site\_id}" - doesnt actually display anything, what it does is grab paramaters such as order, count, category, typeid, and siteid. As you can see in this example, it will grab the latest 5 ad tools within category 2 (hosted galleries)and typeid 2 (free hosted galleries) for siteid of the current site the loop is on.
* "{foreach from=$adtools key=adtool\_id item=adtool\_data}" - will loop through every ad tool defining a variable for both its id and data.
* "{nats\_encode siteid=$siteid programid=1 userid=$toid adtoolid=$adtool\_id}" - will do the nats encode of the current site in the loop with the paramaters of programid, userid, adtoolid which would be the current adtoolid of the loop
* "\<a href="{$encoded}">{$adtool\_data.name}\</a>" - will display the url and the name of the ad tool.
* "{$adtool\_data.description}" - will display the details given in the description for each ad tool.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.toomuchmedia.com/nats-admin/mass-mailing/further-reading/common-mailer-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
