Create categories in SMTP

Sending emails through Acumbamail's SMTP relay allows you to get a lot of information about how your transactional emails are working. Transactional emails are usually the great forgotten in the sending of emails, usually delegated to the web server itself that is responsible for sending them without offering statistics. The problem is that Acumbamail cannot categorize transactional shipments by itself, since they are all made in the same way, being sent individually through our SMTP server. Therefore, inorder to access an advanced analytics of your transactional emails, it is essential to create categories in SMTP. In this article we explain how.

Why creating categories in SMTP is useful

To solve this problem, a header can be programmatically added to the emails to allow them to be categorized. The objective of adding this header is to create a classification of the emails to be able to independently consult their operation. Both the categories and the headers have to be defined by you personally, the following is a simple example:

Email type

Header example (you can put the text you want)

Registration 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 that would be interesting to classify, since a part of the emails may not be working correctly, having little opening or being marked as SPAM by an ISP, and in the total volume of transactional emails 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 to the email. The header you should use is: ACUMBAMAIL-SMTPAPI. Taking into account the previous example of headers, the order confirmation emails will have to include the following information in the header: ACUMBAMAIL-SMTPAPI: ORDER_CONFIRMATION. Below we are going to tell you what changes you have to make regarding the configuration that we explained in this article to add categories.

Create a category in Django

To create this category in Django, once you have configured the Acumbamail SMTP server , 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)

Create 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")

Create 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');