Creating Categories in SMTP

Sending emails through Acumbamail's SMTP relay allows you to obtain a lot of information about how your transactional emails are performing. Transactional emails are often the forgotten ones in email sending, usually delegated to the web server itself which takes care of sending them without offering statistics. The problem is that Acumbamail cannot categorize transactional shipments by itself, as they are all carried out in the same way, being sent individually through our SMTP server. Therefore, in order to access advanced analytics of your transactional emails, it is essential to create categories in SMTP. In this article, we explain how. 

Why it is useful to create categories in SMTP

To solve this problem, you can programmatically add a header to emails to allow categorizing them. The goal of adding this header is to create a classification of emails to be able to independently consult their performance. Both categories and headers have to be defined by you personally, what follows is a simple example:

Email type Header example (you can put any text you want)
Sign up confirmation SIGNUP
Password recovery PASSWORD_RECOVERY
Order confirmation ORDER_CONFIRMATION

This would be an easy example of different emails that any online store would send and it would be interesting to classify, as it may be that a part of the emails is not working correctly, having little opening or being marked as SPAM by some ISP, and in the total volume of transactional emails it will go unnoticed, but if we add a header to each category we can analyze them independently.

How to create a category in SMTP

For emails to have a category, you have to add a header or header to the email.

The header you should use is: ACUMBAMAIL-SMTPAPI.

Considering the previous example of headers, order confirmation emails will have to include the following information in the header: ACUMBAMAIL-SMTPAPI: ORDER_CONFIRMATION.

Next, we are going to tell you what changes you have to make regarding the configuration that we explained in this article to add categories.

Creating a category in Django

To create this category in Django, once you have configured the SMTP server of Acumbamail, you will have to replace your call to send_mail with the following:

from django.core.mail import EmailMessage


email = EmailMessage(
    'subject',
    'message.',
    'from_email',
    to=['to_email'],
    headers={'ACUMBAMAIL-SMTPAPI':  'ORDER_CONFIRMATION'},
)

email.send(fail_silently=False)

Creating a category in Java

To create this category in Java, once you have configured the SMTP server of Acumbamail, you will have to add the custom header by adding the header in the created message object:

message.addHeader("ACUMBAMAIL-SMTPAPI", "ORDER_CONFIRMATION")

Creating a category in PHP

To create this category in PHP, once you have configured the SMTP server of Acumbamail, you will have to add the custom header by adding the header in the created message object:

$mail->addCustomHeader('ACUMBAMAIL-SMTPAPI', 'ORDER_CONFIRMATION');

Still need help? Contact Us Contact Us