Email Templates

Noptin comes with three email templates. To change your email template:-

First, click on Noptin > Settings to open the Noptin settings page.

Next, click on the Emails tab to open the email settings.

open email settings

Finally, set your preferred template in the “Email Templates” drop down…

Select noptin template

… then click on the “Save Changes” button to save your settings.

Save noptin settings

Editing the Email Templates

If you need to make any further changes to the templates, you can take advantage of Noptin’s advanced templating system.

To do this:-

First, create a new folder in your theme’s root folder with the name “noptin” as shown below.

Overide Noptin Templates

Next, copy the “email-templates” folder from “plugins/newsletter-optin-box/templates” into this folder.

Overide Noptin Email Templates

You can then edit the templates as you see fit.

NOTE: This will override all the files in the entire folder. As a result, any changes we make to the original files will not reflect on your site. It is therefore recommended that you keep your templates in sync whenever you update Noptin.

To prevent conflicts with future versions of Noptin, we recommend that you only copy the specific files that you would like to edit. If you do this, remember to maintain the directory structure.

Using your own Email Templates

Before an email template is loaded, Noptin filters the email data through the noptin_mailer_email_data filter as shown below.

Filtering email data before it is sent

You will notice a couple of things that can be really powerful if well utilized.

First, the email data is passed into the filter. This contains a lot of data about the email being built such as ‘campaign_id’ for those emails that were generated from an email campaign.

Second, if the callbacks attached to the above hook do not return a template key in the returned array, the default template that you set above will be used instead.

Third, if the string ‘empty‘ is returned as the template, no template will be used. Instead, the ‘email_body‘ key will be returned.

NOTE: The ‘email_body‘ key is always available on the $data array passed to the filter. This is usually the content of the email as written in the email editor. This filter allows you to pre-process the content before it is rendered inside a template.

What this means is that you can do your own processing on the email then return “empty’ as the template.

It also means that you can pass in the path to a different template and it will be used to load the content.

NOTE: The template can be a path to a single file or a path to a directory/folder containing several template files.

Important Points to Note

Provide a way for your subscribers to unsubscribe

You should always include a way for your subscribers to unsubscribe. This can be achieved by using [[unsubscribe_url]] as the anchor to an unsubscribe link.

Better still, display the footer text that the administrator has set in the admin dashboard as it usually includes a unsubscription link.

For folder-based templates, you can display the footer text by echoing the value of the $footer_text variable which is available in your template files.

For file based templates, this text is available as $data['footer_text'].

Include a Preview Text

Email clients display this text on the email overview screens next to the email subject. Since the Noptin email editor provides a way for administrators to specify a preview text for each email they write, it only makes sense that you display the text in your templates.

For folder-based templates, you can display the preview text by echoing the value of the $preview_text variable which will is available in your template files.

For file based templates, this text is available as $data['preview_text'].

Do not forget to hide the preview text. Failing to do so will result it to being shown when a user is viewing the main email content.

Include a tracking pixel

Noptin uses tracking pixels to know when an email has been opened.

Including one in your template is. All you have to do is is echo the value of the $tracker variable (or $data[‘tracker’]) for those using single file templates.

You do not have to worry about tracking clicks. Noptin will automatically attach that code for you when in post processes the email.


Custom templates make Noptin very powerful. Do take a look at the default template for ideas on how your custom templates should look like.

Still Stuck?   How can we Help?
Updated on

6 thoughts on “Email Templates”

  1. First of all, I’d like to say, Noptin is best plugin ever!
    but I can’t find guide about how to attach ‘unsubscribe’ link on template.
    Please guide me. Thanks!

    1. Hi Natalie,

      Thanks for the kind words.

      You can use the [[unsubscribe_url]] tag as a URL anchor and it will be replaced by the unsubscribe link.

      Below is an example of how the default template does it:-

      <p style="margin: 0;">To stop receiving these emails, you can <a href="[[unsubscribe_url]]" target="_blank" rel="noopener noreferrer nofollow ugc">unsubscribe</a> at any time.</p>
  2. Hi, Thanks for your great Plugin.

    I was wondering if it is possible to use the HTML E-mail Template from the Plugin WP HTML Mail. So that every email that gets sent from my System looks the same and I don’t have to do the same template twice.

    Thanks and all the best,

    Kevin Lambert

Leave a Reply

Your email address will not be published. Required fields are marked *

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation