How to Transition from Mailgun to Elastic Email API » intelfindr


Altering your e-mail API supplier may be swift and hassle-free. Utilizing the instance of switching from Mailgun to Elastic Email, we have put collectively an e-mail API migration information for you. You will see that all the data you want to begin utilizing our platform – variations in terminology, our sources, libraries, documentation, and the way to combine with our e-mail API step-by-step.

API libraries

We've ready and continually preserve API libraries for varied programming languages and frameworks. Our downloadable libraries are sometimes accompanied by guides for authentication, code samples, and different helpful sources. We presently have libraries for 12 languages:

If you happen to can't discover the library you’re on the lookout for, tell us at contact@elasticemail.com.

How to get began

Allow us to stroll you thru all of the steps you want to take to arrange your Elastic Email account, combine with our e-mail API, and begin sending emails.
We additionally ready complete API documentation so to combine with our e-mail API and use it in accordance to your sending wants. Taking a look at API documentation is one of the simplest ways to see the distinction between e-mail service suppliers. To simplify issues, we ready a comparability of essentially the most important API references for each Elastic Email and Mailgun:

Signing up

To get began, join an Elastic Email account. Select the Email API product and create your account without spending a dime. No bank card particulars are required. You'll then obtain a affirmation e-mail to confirm your profile.

Organising a sending area

When you created your Elastic Email account, it’s time to add your sending area and confirm it by including the DNS settings. Try our assist article to learn the way to confirm your area step-by-step, or watch our information video beneath:

Creating your API Key

To supply legitimate authentication and begin utilizing our API, you will have an API key. To generate your API key, enter settings in your Elastic Email account and go to Settings -> Handle API Keys -> Create.

At this level, you possibly can set customized permissions and non-obligatory entry on your API key.

When you create your API key, preserve it secure as it is going to be used for each API name you make so as to establish you and make sure your account’s credentials. You possibly can create up to 15 API keys. 

Your API key needs to be despatched contained in the header with the parameter title ‘x-elasticemail-apikey’ and your API key as a price.

Putting in API library

To start out sending emails through our e-mail API, we extremely advocate downloading a repository of the programming language you utilize and putting in it. Each Mailgun and Elastic Email have a wealthy collection of e-mail API libraries and SDKs of many programming languages. It'll make the migration course of very simple and handy for you. Simply as with Mailgun's e-mail API integration you put in a library or SDK, you want to do the identical with Elastic Email. Do not forget that all our downloadable repositories can be found on Github.

Let’s present you the set up course of utilizing JavaScript. For instance, while you need to set up the repository for Node.js.

Npm

To publish the library through npm, please observe the process in “Publishing npm packages“.

Then set up it through:

npm set up @elasticemail/elasticemail-shopper --save

Sending your first e-mail

Allow us to first check out what sending an e-mail through Mailgun API appears to be like like:

const formData = require('form-data');
  const Mailgun = require('mailgun.js');
  const mailgun = new Mailgun(formData);
  const mg = mailgun.shopper( 'key-yourkeyhere');
mg.messages.create('sandbox-123.mailgun.org', {
    from: "Excited User ",
    to: ["test@example.com"],
    topic: "Hi there",
    textual content: "Testing some Mailgun awesomness!",
    html: ""
  })
  .then(msg => console.log(msg)) // logs response information
  .catch(err => console.error(err)); // logs any error

If you need to ship your first e-mail through Elastic Email, you want to load the library, get shopper occasion, use your newly generated Elastic Email API key, and create an occasion of EmailsApi that can be used to ship the e-mail. The 'key-yourkeyhere' for the API key in Mailgun is now changed by "YOUR_API_KEY"

Based mostly on the JavaScript instance, right here’s the entire code for sending an e-mail to copy and paste:

const ElasticEmail = require('@elasticemail/elasticemail-client');

const shopper = ElasticEmail.ApiClient.occasion;

const apikey = shopper.authentications['apikey'];
apikey.apiKey = "YOUR_API_KEY";

const emailsApi = new ElasticEmail.EmailsApi();
const emailData = {
    Recipients: [
        {
            Email: "johnsmith@domain.com",
            Fields: {
                name: "John"
            }
        }
    ],
    Content material: {
        Physique: [
            {
                ContentType: "HTML",
                Charset: "utf-8",
                Content: "Hi {name}!"
            },
            {
                ContentType: "PlainText",
                Charset: "utf-8",
                Content: "Hi {name}!"
            }
        ],
        From: "myemail@domain.com",
        Topic: "Example email"
    }
};

const callback = (error, information, response) => {
    if (error) {
        console.error(error);
    } else {
        console.log('API known as efficiently.');
        console.log('Email despatched.');
    }
};
emailsApi.emailsPost(emailData, callback);

Email API Migration information: wrapping up

We hope you at the moment are outfitted with all of the important data and sources you want to migrate to our e-mail API. You probably have any questions or want further help, our buyer help skilled can be pleased to aid you from day one. They're out there to you 24/7 through e-mail at help@elasticemail.com or through stay chat, which you will discover within the backside proper nook of our web site and platform. 
Haven’t you signed up for an Elastic Email account? Strive it out and begin sending emails with us right this moment!

If you happen to like this text, share it with pals:

Ula Chwesiuk

Ula is a content material creator at Elastic Email. She is captivated with advertising, inventive writing and language studying. Exterior of labor, Ula likes to journey, attempt new recipes and go to live shows.



Source link

Share.
Leave A Reply

Exit mobile version