decor decor

24/7 Customer Support

Our Customer Support team is here for you 24/7 to give you any help you need, ranging from simple troubleshooting to giving you advanced tips and tricks for better deliverability. Whatever you need, our agents are here for you!

Try for Free

Integrate easily thanks to API libraries

Our collection of API libraries for various programming languages and frameworks will help you speed up your integration and make it more efficient.

Copied!
# install library: npm install @elasticemail/elasticemail-client

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

let defaultClient = ElasticEmail.ApiClient.instance;

let apikey = defaultClient.authentications['apikey'];
apikey.apiKey = "895A382DF3DCC13A97E72EXAMPLEKEY"

let api = new ElasticEmail.EmailsApi()

let email = ElasticEmail.EmailMessageData.constructFromObject({
  Recipients: [
    new ElasticEmail.EmailRecipient("MeowWow ")
  ],
  Content: {
    Body: [
      ElasticEmail.BodyPart.constructFromObject({
        ContentType: "HTML",
        Content: "My test email content ;)"
      })
    ],
    Subject: "JS EE lib test",
    From: "MyEmail "
  }
});

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
api.emailsPost(email, callback);
// Add Nuget package ElasticEmail to the project
// https://www.nuget.org/packages/ElasticEmail/

using System.Diagnostics;
using ElasticEmail.Api;
using ElasticEmail.Client;
using ElasticEmail.Model;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var config = new Configuration();
            config.ApiKey.Add("X-ElasticEmail-ApiKey", "895A382DF3DCC13A97E72EXAMPLEKEY");

            var apiInstance = new EmailsApi(config);

            try
            {
                var messageData = new EmailMessageData(
                    new System.Collections.Generic.List()
                    {
                        new EmailRecipient("MeowWow ")
                    },
                    new EmailContent(
                        new System.Collections.Generic.List()
                        {
                            new BodyPart()
                            {
                                ContentType = BodyContentType.HTML,
                                Content = "My test email content ;)"
                            }
                        },
                        subject: "EE C# lib test",
                        from: "MyEmail "
                    )
                );

                var apiResponse = apiInstance.EmailsPost(messageData);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling EmailsPost: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}
# install EE library: pip3 install ElasticEmail

import ElasticEmail
from ElasticEmail.api import emails_api
from ElasticEmail.model.email_message_data import EmailMessageData
from ElasticEmail.model.email_recipient import EmailRecipient
from ElasticEmail.model.email_content import EmailContent
from ElasticEmail.model.body_part import BodyPart
from pprint import pprint

configuration = ElasticEmail.Configuration()
configuration.api_key['apikey'] = '895A382DF3DCC13A97E72EXAMPLEKEY'

with ElasticEmail.ApiClient(configuration) as api_client:
    api_instance = emails_api.EmailsApi(api_client)
    email_message_data = EmailMessageData(
        recipients=[
            EmailRecipient(
                email="MeowWow "
            ),
        ],
        content={
	    "Body": [
		{
		    "ContentType":"HTML",
		    "Content":"My test email content ;)"
		}
	    ],
	    "Subject": "Python EE lib test",
	    "From": "MyEmail "
	}
    )

    try:
        api_response = api_instance.emails_post(email_message_data)
        pprint(api_response)
    except ElasticEmail.ApiException as e:
        print("Exception when calling EmailsApi->emails_post: %s\n" % e)
# install library: gem install ElasticEmail (may require installation of ruby-dev in the system)

require 'ElasticEmail'

ElasticEmail.configure do |config|
  config.api_key['apikey'] = '895A382DF3DCC13A97E72EXAMPLEKEY'
end

api_instance = ElasticEmail::EmailsApi.new

email = ElasticEmail::EmailMessageData.new(
  Hash[
    "recipients" => [ ElasticEmail::EmailRecipient.new(Hash["email" => "MeowWow "]) ],
    "content" => ElasticEmail::EmailContent.new(
      "body" => [ ElasticEmail::BodyPart.new(
        "content" => "My test email content ;)",
        "content_type" => "HTML"
        ) ],
      "subject" => "Ruby EE lib test",
      "from" => "MyEmail "
    )
  ]
)

begin
  api_instance.emails_post(email)
rescue ElasticEmail::ApiError => e
  puts "Exception when calling EE API: #{e}"
end
# 1) install php and php-curl module
# 2) install composer (https://getcomposer.org/)
# 3) create composer.json file:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/elasticemail/elasticemail-php.git"
    }
  ],
  "require": {
    "elasticemail/elasticemail-php": "*@dev"
  }
}

# 4) run composer install

# 5) write and run your script

require_once('vendor/autoload.php');

$config = ElasticEmail\Configuration::getDefaultConfiguration()
        ->setApiKey('X-ElasticEmail-ApiKey', '895A382DF3DCC13A97E72EXAMPLEKEY');

$apiInstance = new ElasticEmail\Api\EmailsApi(
    new GuzzleHttp\Client(),
    $config
);

$email = new \ElasticEmail\Model\EmailMessageData(array(
    "recipients" => array(
        new \ElasticEmail\Model\EmailRecipient(array("email" => "mail@contact.com"))
    ),
    "content" => new \ElasticEmail\Model\EmailContent(array(
        "body" => array(
            new \ElasticEmail\Model\BodyPart(array(
                "content_type" => "HTML",
                "content" => "My content"
            ))
        ),
        "from" => "email@domain.com",
        "subject" => "My Subject"
    ))
));

try {
    $apiInstance->emailsPost($email);
} catch (Exception $e) {
    echo 'Exception when calling EE API: ', $e->getMessage(), PHP_EOL;
}
/* Initialization */
import { Configuration, EmailsApi, EmailMessageData } from '@elasticemail/elasticemail-client-ts-axios';

/* Generate and use your API key */

const config = new Configuration({
    apiKey: "YOUR_API_KEY"
});

const emailsApi = new EmailsApi(config);

const emailMessageData = {
    Recipients: [
      { 
        Email: "MeowWow ",
        Fields: {
          name: "Name"
        }
      }
    ],
    Content: {
      Body: [
        {
          ContentType: "HTML",
          Charset: "utf-8",
          Content: "My test email content ;)"
        },
        {
          ContentType: "PlainText",
          Charset: "utf-8",
          Content: "Hi {name}!"
        }
      ],
      From: "MyEmail ",
      Subject: "Typescript Axios EE lib test"
    }
  }; // interface EmailMessageData from '@elasticemail/elasticemail-client-ts-axios'

const sendBulkEmails = (emailMessageData: EmailMessageData): void => {
  emailsApi.emailsPost(emailMessageData).then((response) => {
      console.log('API called successfully.');
      console.log(response.data);
  }).catch((error) => {
      console.error(error);
  });
};

sendBulkEmails(emailMessageData)
# download our ElasticEmail-WebApiClient and the library
# to install this module, run the following commands: 
# perl Makefile.PL
# make
# make test
# make install

use Data::Dumper;
use ElasticEmail::EmailsApi;
use ElasticEmail::Object::EmailMessageData;
use ElasticEmail::Object::EmailRecipient;
use ElasticEmail::Object::EmailContent;
use ElasticEmail::Object::BodyPart;
my $api_instance = ElasticEmail::EmailsApi->new(

    # Configure API key authorization: apikey
    api_key => {'X-ElasticEmail-ApiKey' => 'YOUR_API_KEY'},
    # uncomment below to setup prefix (e.g. Bearer) for API key, if needed
    #api_key_prefix => {'X-ElasticEmail-ApiKey' => 'Bearer'},
);

my $email_message_data = ElasticEmail::Object::EmailMessageData->new(); # EmailMessageData | Email data
my $recipient = ElasticEmail::Object::EmailRecipient->new();
$recipient->email("MyEmail ");

my $content = ElasticEmail::Object::EmailContent->new();

my $body = ElasticEmail::Object::BodyPart->new();
$body->content('My test email content ;)');
my $body_content_type = 'HTML';
$body->content_type($body_content_type);
$content->body([$body]);

$content->reply_to('MyEmail ');
$content->from('MyEmail ');
$content->subject('Perl EE lib test');
$content->template_name('template name');


$email_message_data->recipients([$recipient]);
$email_message_data->content($content);

eval {
    my $result = $api_instance->emails_post(email_message_data => $email_message_data);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling EmailsApi->emails_post: $@\n";
}
# download and install the lib from ElasticEmail repository and make sure the script has executable rights: $ chmod u+x ElasticEmail

#!/bin/bash

host=https://api.elasticemail.com

apiKey=YOUR_API_KEY

apiKeyHeaderName=X-ElasticEmail-ApiKey
apiKeyHeader=$apiKeyHeaderName:$apiKey

apiMethod=emailsPost

json='{
        Recipients: [
            { 
                Email: "MeowWow ", 
                Fields: {
                    name: "MeowWow"
                }
            }
        ],
        Content: {
            Body: [
                {
                    ContentType: "HTML",
                    Charset: "utf-8",
                    Content: "My test email content ;)"
                },
                {
                    ContentType: "PlainText",
                    Charset: "utf-8",
                    Content: "Hi {name}!"
                }
            ],
            From: "MyEmail ",
            Subject: "Bash EE lib test"
        }
    }'

echo $json | ./ElasticEmail --host $host --content-type json $apiMethod - $apiKeyHeader

Let’s send your first email!

1. Register a free account

Register and activate your account to get access to our product.

2. Verify your domain

Follow the instructions on our settings page to verify your domain and start sending with us.

3. Create an API Key

Go to your settings to generate an API Key to add to your code later.

4. Install our libraries

Head to our GitHub page to find a library suitable for the language you’re using.

5. Send an email

Use the provided code snippets to send out a simple test email. Want to learn more? Check out our documentation and Github.

Plug into existing software

Do you use a CMS to manage your content? Did you implement marketing automation or CRM software? Elastic Email integrates easily with some of the most popular software.

Elastic Email is a leader in Small-Business Transactional Email on G2 Elastic Email is a leader in Transactional Email on G2
Ready to get started?

Try out our Email API service now!
Start sending for free with 100 emails/day and upgrade anytime.

Set up in 2 minutes

No credit card required