📜 ⬆️ ⬇️

How to use the HTTP API to send emails

Communication technologies have reached a stage where it was not enough to use one or two channels. Each channel has its advantages and disadvantages, and this is an indisputable fact. You can use push notifications to target and reach users in a specific region. SMS is usually always read. Viber gives interactive communication and entertainment content. Emails don't bother clients.

In any case, today's client-oriented ecosystem requires you to adapt communication strategies to the needs of the client. Many already have a platform on which to base their choices. They already use Gmail, Facebook Messenger or Viber and Outlook, as well as a number of other applications. The key factor is that they use each of these channels for specific purposes.

For example, some use Messenger to conduct conversations in real time. At the same time, they prefer to receive newsletters from brands through Gmail. Some want to be contacted via SMS, as this is still the most reliable channel of communication. There are customers who prefer to receive voice calls in case of important notifications. There is no doubt that your client base requires the use of various methods to fully cover it.
')


Why email?


Due to its unique structure, e-mail remains an essential part of multi-channel communications. This is one of the most economical and unobtrusive channels, which makes it one of the preferred ways to communicate with the brand. We're talking about newsletters, but there are a number of other cases in which email works best. From account verification to resetting passwords and restoring accounts.

That's why billions of emails are sent daily by email. According to Ericsson , by 2020, 70% of the world's population will use smartphones, and 90% will enter the coverage area of ​​the global mobile network. It is also important to note that over 50% of emails are read from mobile devices, not from the desktop, and this number continues to grow. Which means that users will be able to access their accounts at any time.

Our HTTP API offers simple and feature-rich emails; You can send HTML-messages with attachments and view logs and delivery reports. However, before you start sending emails, you need to create a valid Infobip account .

How to create an account


If you use our other services through the API, you already have a valid Infobip account, and you can use it to send emails.

Consider in advance all the issues that are associated with the domain, since the reputation of the email sender is closely related to the domain name and the IP address. Reputation problems arise when you turn into a “bad” sender, and this can greatly affect the status of the domain. The “bad” sender will spend enormous resources to regain his credibility. So keep in mind that splitting domains by type of message you send is a good idea.

If you have not thought out your plan for the domain - do not worry. You can use our test domain to familiarize yourself with the service, and later start using your own domain. After choosing your preferred domain, you will need to contact your account manager, and then we will be able to integrate the domain into our platform. After receiving additional instructions on configuring DNS and establishing the right channel of communication between your domain and platform, you can proceed to the next step and begin a successful email distribution.
Feel free to ask any questions and email us at: support@infobip.com.

Let's send Email


After creating your account you can send emails. You can send a simple letter or enriched content letter. If you decide to start sending simple letters, it will mean that you send a single email message to only one address through the request:



On the other hand, you can send multi-functional e-mails , which are messages with attachments (attachments) sent to one or many addresses:



With the answer (the picture is clickable):



This is an example of an email with one attachment that is sent to two addresses. If you want to send an email with several attachments, enter in the request parameters for several attachments.

The header of the HTTP status code will be 200 OK on successful sending, and if you try to send a message without authorization, you will receive an Unauthorized error code 401 .

Email Delivery Reports and Shipping Logs


Email Delivery Reports


After sending the email, you will receive a one-time delivery report . Delivery reports confirm that the email you sent was successfully delivered. Reports can only be received once, and after receiving the report you will not be able to request it again.

You can enter parameters to receive delivery reports, and you can also make requests without any parameters:



Result (clickable image):



The delivery report without any parameters will provide you with detailed information about the sent e-mails, including the status of the letter, the message ID, the time and date of sending / receiving the letter, error information, etc.

You can also get a delivery report by using messageId:



Another possibility is two initial delivery reports:



Both requests show the details of the message as a request with no parameters, but the difference is that the messageID query retrieves information about a specific message, and the two delivery reports provide information about the two initial messages.

Email logs


As with delivery reports, dispatch logs provide additional information about sent messages. The key difference is that the logs are available within the last 48 hours, you can query them any number of times, and you will see the result by the messages regardless of their current status:

Result (clickable image):



The response will contain information about all emails sent through the Infobip platform in the last 48 hours. None of the queries are required for this type, but if you need to find a specific message, you can use filtering options .

For example, logs can be obtained through one or, in our case, through several message IDs:



Also, a combination of parameters will help you more accurately filter messages:



This request has two filters (parameters) - sentSince and generalStatus , which will be identified as a single parameter, and the response will contain a message log with all sent and delivered emails from the date of the request.

The status code will be the same as for sent messages; The HTTP status code response header will look like 200 OK upon successful sending, and message logs and delivery reports will also be returned, but if you try to send a message without authorization, you will receive a response with the HTTP status code 401 Unauthorized .

This article should help you with the HTTP API integration process.

Source: https://habr.com/ru/post/327594/


All Articles