If you’ve decided to move from MailerSend to Elastic Email, congratulations! Welcome onboard and we look forward to helping you migrate from one email API to another. We prepared this email API migration guide so that you get all the information you need to start using our product. In this article, you will find everything about our API libraries and documentation, how to get started and send your first email with Elastic Email.
API libraries
To make it easier for you to integrate with our email API, we have prepared and constantly maintain downloadable API libraries for 12 programming languages and frameworks. They are often accompanied by guides for authentication, code samples, and other useful resources. Here are our libraries:
If you cannot find the library you’re looking for, let us know at contact@elasticemail.com.
How to get started
Now it’s time to walk you through all the essential steps to set up your Elastic Email account, integrate with our email API, and start sending emails.
We also prepared comprehensive API documentation so that you can integrate with our email API and use it according to your sending needs. Looking at API documentation is the best way to see the difference between email service providers. To simplify matters, we prepared a comparison of the most essential API references for both Elastic Email and MailerSend:
API Name |
||
Introduction |
Introduction | Introduction |
Authentication |
Authentication | Authentication |
Sending Emails |
Emails | Sending an email |
Managing Suppressions |
Suppressions | Suppressions |
Managing Templates |
Templates | Templates |
Inbound Email Processing |
Inbound Route | Inbound Routing |
Statistics |
Statistics | Analytics |
Signing up
First, you need to create an Elastic Email account. Choose the Email API product and sign up for free. You do not need to provide any credit card information. After the registration, you will get a confirmation email to verify your account.
Setting up a sending domain
One of the first steps after creating your Elastic Email account will be to add and verify your sending domain. For example, you will need to set up the DNS settings of your domain. Check out our help article to learn how to verify your domain step-by-step, or watch our guide video below:
Creating your API Key
The next crucial step is to generate an API key. You will need it to provide authentication to send emails via our API. To generate your API key, enter settings on your Elastic Email account and go to Settings -> Manage API Keys -> Create.
At this point, you can set custom permissions and optional access for your API key.
Once you create your API key, keep it safe as it will be used for every API call you make in order to identify you and confirm your account’s credentials. You can create up to 15 API keys.
Your API key should be sent inside the header with the parameter name ‘x-elasticemail-apikey’ and your API key as a value.
Installing API library
We highly recommend you download and install a repository of the programming language you use to start sending emails via our API. Both MailerSend and Elastic Email have a rich selection of email API libraries and SDKs of many programming languages. It will make the migration process very easy and convenient for you. Just as with MailerSend's email API integration you installed a library or SDK, you need to do the same with Elastic Email. Remember that all our downloadable repositories are available on Github.
Let’s show you the installation process using JavaScript. For example, when you want to install the repository for Node.js.
Npm
To publish the library via npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install @elasticemail/elasticemail-client --save
Sending your first email
Let us first take a look at what sending an email via MailerSend API looks like:
import 'dotenv/config';
import { MailerSend, EmailParams, Sender, Recipient } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
const sentFrom = new Sender("you@yourdomain.com", "Your name");
const recipients = [
new Recipient("your@client.com", "Your Client")
];
const emailParams = new EmailParams()
.setFrom(sentFrom)
.setTo(recipients)
.setReplyTo(sentFrom)
.setSubject("This is a Subject")
.setHtml("<strong>This is the HTML content</strong>")
.setText("This is the text content");
await mailerSend.email.send(emailParams);
If you want to send your first email via Elastic Email, you need to load the library, get client instance, use your newly generated Elastic Email API key, and create an instance of EmailsApi that will be used to send the email. The 'API_KEY'
for the API key in MailerSend is now replaced by "YOUR_API_KEY"
.
Based on the JavaScript example, here’s the whole code for sending an email to copy and paste:
const ElasticEmail = require('@elasticemail/elasticemail-client');
const client = ElasticEmail.ApiClient.instance;
const apikey = client.authentications['apikey'];
apikey.apiKey = "YOUR_API_KEY";
const emailsApi = new ElasticEmail.EmailsApi();
const emailData = {
Recipients: [
{
Email: "johnsmith@domain.com",
Fields: {
name: "John"
}
}
],
Content: {
Body: [
{
ContentType: "HTML",
Charset: "utf-8",
Content: "<strong>Hi {name}!<strong>"
},
{
ContentType: "PlainText",
Charset: "utf-8",
Content: "Hi {name}!"
}
],
From: "myemail@domain.com",
Subject: "Example email"
}
};
const callback = (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
console.log('Email sent.');
}
};
emailsApi.emailsPost(emailData, callback);
Email API Migration guide: wrapping up
Now you know all the essential steps on how to migrate from MailerSend to Elastic Email. If you have any questions about how to integrate with our email API, do not hesitate to contact our customer support team via live chat on our website or in our app, or at support@elasticemail.com. They are available for you 24/7 from day one.
Haven’t you signed up for an Elastic Email account? Try it out and start sending emails with us today!