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 working. Transactional emails are often forgotten when sending emails, usually delegated to the web server itself, which is responsible for sending them without offering statistics . The problem is that Acumbamail cannot categorize transactional emails by itself, since 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.
In this article
Why it is useful to create categories in SMTP
To solve this problem, you can programmatically add a header to the emails to allow them to be categorized. The purpose of adding this header is to create a classification of the emails so that you can independently check their performance. Both the categories and the 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) |
Confirmation of discharge | 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 some of the emails may not be working correctly, having few openings 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 will be able to analyze them independently.
How to create a category in SMTP
In order for emails to have a category, you need to add a header to the email. The header you need to use is: ACUMBAMAIL-SMTPAPI. Taking into account the header example above, order confirmation emails will need to include the following information in the header: ACUMBAMAIL-SMTPAPI: ORDER_CONFIRMATION. Below we will tell you what changes you need to make to the configuration we explained in this article to add categories.
Creating 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 Acumbamail SMTP server , 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 Acumbamail SMTP server , you will have to add the custom header by adding the header in the created message object:
$mail->addCustomHeader('ACUMBAMAIL-SMTPAPI', 'ORDER_CONFIRMATION');