Questions? Feedback? powered by Olark live chat software

Articole din categoria "Tech"

How to tag your emails X-NZ-Tags

For transactional emails, reporting is usually calculated per day, since there is no such thing as a campaign. Transactional emails are usually one to one. We have come up with Tag concept for emails in order to group some emails (by tags). By using the email tags, it’s now easy to check reports for a specific group of emails. For example: order_confirmation or signup.

NewsmanSMTP supports multiple tags per email.

Adding the tags is straight forward: Use X-NZ-Tags email header. Tags are separated by comma.


X-NZ-Tags: order_confirmation,customer_101

The email tagging feature is also supported in the REST API.
Tags can pe added in the message.send method.

Custom mail tracking via X-NZ-Track header

Some of our users requested more flexibility when choosing how they want their emails to be tracked.

We have implemented the mail header X-NZ-Track which can take any of the following options separated by comma:

  • open – enable email open tracking by adding the pixel image
  • click – enable tracking of links in both html and plain text version
  • txt_click – enable tracking of links just in the plain text version
  • html_click – enable tracking of links just in the html version

If the header is used it overrides acount settings.


X-NZ-Track: open,click
// tracks both open and click in html and plain text version

X-NZ-Track: txt_click
// tracks just click in plain text version

Email Metadata for later tracking

We’ve released a quick update today which allows you to “identify” easily every email sent.
For this we have a new email header: X-NZ-Metadata.

All data sent in this email header will be saved to the database and later on can be retrieved by API call:

Also the value of the X-NZ-Metadata header will be sent with all webhook calls in the meta array.

Here is a quick example of adding custom email header X-NZ-Metadata with Swift mailer:

        ->addTextHeader("X-NZ-Metadata", "My custom string: ID or JSON, etc.");

Custom parameters (tags) inside your emails

Some of our customers requested unsubscribe links inside the transactional emails. We just had to copy some code from the sister project: NewsmanApp and voilla.

Supported parameters (tags):
##NEWSMAN:unsubscribe## – will generate an unique unsubscribe link
##NEWSMAN:view_online## – will generate a unique view online link

Quick example:

You can unsusbscribe by clicking <a href="##NEWSMAN:unsubscribe##">here</a>.

Events API – Webhook

NewsmanSMTP can notify your application when one of these events happen:

  1. bounce – an email bounces back
  2. spam – somebody clicks report spam
  3. unsub – somebody unsubscribes
  4. reject – when we reject (refuse to send) one of your emails
  5. view – an email is opened (viewed)
  6. click – a link is clicked

The events are sent via POST to your webhook URL (@see settings page). Please use https (secure) URL for the webhook, for security reasons.

The events are batched up and sent as an array of events (one or more events can be sent in one request). The format of the event if quite easy. One parameter is sent via POST named newsman_events. The value of newsman_events is a JSON encoded string which is a LIST of events.

Each event is a hash map (dict) with following keys:

  • id – the event id
  • timestamp – integer timestamp (date of the event)
  • type – event type (@see above available types)
  • data – hash map (dict) with event related meta data

Here is an example of how to parse an event in PHP:

    [newsman_events] => [{"timestamp": 1382717823, "type": "reject", "id": "e24a6268-3d90-11e3-8080-808080808080", "data": {"send_id": "237aa4c2-5d42-11e6-b2f1-1dd49f2225ea", "meta": {"reason": "softbounce", "subject": "You have received a new message."}, "email": "new@email.todo"}}]
$newsman_events = json_decode($_POST["newsman_events"], true);
    [0] => Array
            [timestamp] => 1382717823
            [type] => reject
            [id] => e24a6268-3d90-11e3-8080-808080808080
            [data] => Array
                    [send_id] => 237aa4c2-5d42-11e6-b2f1-1dd49f2225ea
                    [meta] => Array
                            [reason] => softbounce
                            [subject] => You have received a new message.
                    [email] => new@email.todo

The data value will be a hash map (dict) with at least these 2 keys (email and meta). The meta is it’s self a hash map (dict) with event specific data.

Specific event meta keys are listed below by type.

  1. bounce – bounce_error_message, bounce_smtp_status, is_no_user_found, email_head
  2. spam – feedback_msg
  3. unsub – ip (optional), useragent (optional)
  4. reject – reason
  5. view – ip, subject, useragent, url (optional)
  6. click – ip, subject, useragent, url