Custom Email Header

Hi all,

Does anyone know a way to add a custom email header to outbound emails being sent with the ‘Send an email’ automation?

Thanks

Not sure what you’re really looking for here, so I’m no help. sorry

1 Like

Hi @CarsonRedCliffLabs thank you for trying and sorry for any confusion my lack of descriptive question may have caused anyone. I expected the answer to be no I just was trying to check before I went down a different route.

For those of you who didn’t know what I was asking and would like to and why then I will try and explain. I warn now this could get boring

An email is put in a simple way made up of two fundamental parts:

  1. Header
  2. Body

Some people used to describe the header as the envelope and the body as the letter inside. Now as with all these examples, it’s way more complicated than that however it is close enough.

The header has the ‘To:’ address and the ‘From:’ and also a brief description of what is inside ‘Subject:’ however, it does and can include a lot of additional information that these days we don’t see.

Email clients/handlers choose to hide most of the header information and pick what parts of it to show For example Tape chooses not to make the ‘To:’ available for mapping when you get an email sent to Tape - I really must raise a request for that.

An example full header:

From: Jason Melotte <@jmc.tools>
Date: Mon, 13 Nov 2023 18:49:30 +0000
Subject: Contact Follow-Up
Message-Id: <b9c1afab-0323-470c-945e-f37bf54>
Reply-To: @inbound.jmc.tools
To: je
Feedback-ID: s11900269-_:s11900269:
X-Complaints-To: abuse@
X-Job: 297873_11900269
X-PM-Message-Id: b9c1afab-0323-470c-945e-f37bf54fa831
X-PM-RCPT: |bTF8Mjk3ODczfDExOTAwMjY5fGplbkAzanMubWU=|
X-PM-Message-Options: v1;1.dQJoy2OGXSm3KbQXnQseJQ.bLaozR_Ci4C04BervetZjfd3TOZfUpg8ejaTnc1A2z5y9jgg3gD4PoN3c6Y95wj8G0F0ADMF2_9pdKDZKXX9R5lgqurIwzabkVQ-HhOC59veUqpaBIZeMrw03JL_cGp5ElESgDzsDZ-vg1-Y0xkdbbQ9OK2NSotnbHE2gHRfFLRoAyjMdINvFGB2TJzlV1u-
X-dkim-options: s=20231027093248pm;d=jmc.tools
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary=mk3-b6b298e900b2465e887b08bdeb757802; charset=UTF-8

--mk3-b6b298e900b2465e887b08bdeb757802
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

In the above example, I have tried to ‘sanitise’ it whilst also leaving it intact so you can see the type of data that is in a header.
What you technically can do is also inject additional information of your choice into the header for example maybe the record ID of the record the email related to maybe like:

X-Tag: @record ID

Then when certain events happen on your email (if you are passing it through a suitable system) those events can be passed back into Tape via a webhook and then using the new ‘Tag’ can be matched up, events could include:

  • Message Delivery
  • Message Bounce
  • Link clicks

A webhook delivery payload could look something like this:

{
  "RecordType": "Delivery",
  "MessageID": "00000000-0000-0000-0000-000000000000",
  "Recipient": "john@example.com",
  "Tag": "welcome-email",
  "DeliveredAt": "2023-11-14T13:30:38Z",
  "Details": "Test delivery webhook details",
}

So let’s say someone fills a form on your website and you put that data into Tape then you want Tape to send them an email back acknowledging receipt that’s great but it would be nice to know when the email was opened, links clicked and most importantly if the email bounced and that is were an injected ‘Tag’ comes in.

Ways around it

Method one: If you have an app with all your sent emails in (you don’t need to forward your email into it, just create a new record as you send the email with the key information) then when your email is delivered (you probably need to do the same with bounce notifications) have that notification sent in and do a search for the email address that will come along with the delivery notification, also make the search for records with no message id, restrict that search to a single result and this should give you the latest email you sent to the person which should be the one you are getting the delivery notification about - I know that’s a lot of if’s and shoulds.

Once we match the record we can mark it as delivered and add the message id that will likely come with a delivered payload. From now on we can search for the message id to match subsequent notifications making it more reliable.

This method is definitely not without its issues and I am sure would not be 100% reliable so should definitely be used with care.

Around this point anyone who is still reading will be asking ‘If every email has a message id why can we not use this from the start rather than a ‘Tag’?’ Well that is because we don’t know the message id is generated by the sending SMTP server which is a step away from Tape.

Method Two: Send the email via API, build your email in a script along with your special ‘Tag’ and post it off to your provider via their API now this seems a bit of a shame as Tape has that nice built-in email builder but if you need/want that data back in Tape reliably its probably the best option.

Now interestingly (well at least to me) as Tape have now added oAuth 2 support if you are a MS365 user I believe it should be possible to send emails out via your 365 account utilising Microsoft Graph API

Well done if you got all the way here :slight_smile: maybe there was something useful for you, but that is what I was asking adding a custom email header.

2 Likes

@Jason I know it would probably be better to do everything from Tape, but I highly recommend using Mandrill for all your email needs, specifically due to the fact that their API is amazing. Not only do you not need to bother with oAuth2 (you can just use a standard token), but you can use the API to configure custom headers, and then within the Mandrill app itself, you can configure custom webhooks on actions such as clicks and opens, and even define specific rules for when these webhooks should be called.

Mandrill also has a specific “metadata” key where you can fill it with whatever JSON data you want, and then when the webhooks come in, you can easily connect the events to the original context.

2 Likes

Thanks, @andrew.cranston, the question actually came up because I was trying to use an external provider (Amazon SES) but I was a little lazy and still trying to use SMTP. I have since redone it all to send and receive via API which as you say opens up a whole raft of options and I would highly recommend it.

Postmark is another option that is actually my favourite, I should try Mandrill though as I have not used that one before.

1 Like

One of the things I really love about Mandrill is how easy it is to have multi domain support. You can install as many domains as you like and then use a single token to send emails from all of those domains, even if the addresses don’t exist. There’s also features for inbound transactional addresses as well.