If you’re sending emails directly through our SMTP server (instead of using our API or interface), you can still attach the outgoing email to a contact and provide custom variables to personalize your email templates. Keep in mind this is an optional feature.
1. Attaching an Email to a Contact
To associate an outgoing email with a specific contact, you need to include the contact ID in the email headers.
Header Name:
X-Contact-ID
Header Value: The ID of the contact
Example:
X-Contact-ID: ctc_1234
Important Note:
If the specified contact ID does not exist, the outgoing email will fail. Ensure that the contact ID is valid and corresponds to an existing contact in your database.
2. Adding Custom Variables to Your Email
To send custom variables that can be used within your email templates, include a header with the following details:
Header Name:
X-Variables
Header Value: A JSON object containing all the variables you want to use
Example:
X-Variables: {"firstName": "John", "lastName": "Doe", "discountCode": "SAVE20"}
How It Works:
These variables can then be referenced within your email template.
For instance, if your template uses a variable like
{{firstName}}
, the value"John"
will be injected at runtime.The total size of the JSON payload is limited to 2MB.
Example SMTP Email Headers
Here’s an example of how your email headers might look when attaching a contact and sending custom variables:
X-Contact-ID: 12345
X-Variables: {"firstName": "John", "lastName": "Doe", "discountCode": "SAVE20"}
Header Privacy
The headers you include, such as X-Contact-ID and X-Variables, are for internal processing purposes only. These headers will not be forwarded to the recipient’s email address. They are automatically filtered out before the email is delivered to ensure privacy and seamless communication.