Send Emails Using AJAX – Mandrill API Example

Send Emails Using Ajax and Mandrill

Sometimes we find ourselves needing to integrating automatic emails into our applications. It’s possible to do it with just Javascript and jQuery, with no need for a server side language such as php. In my example, I’ll be using the Mandrill API, which provides for 12,000 free emails per month.

In short, the steps are:

  1. register for Mandrill to get an API key
  2. load jQuery
  3. use $.ajax to send an email

Step 1: Get an API key from Mandrill

Get

Sign up for Mandrill. When you’re done, click on Get API Keys


Copy Mandrill API Key

On the next screen, press +Add API Key and copy your key

Step 2: Load jQuery & Mandrill API

<script src=”//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script>

Step 3: Use the $.ajax function to send an email

Here’s a working example with everything coming together:

See the Pen Send Emails Using AJAX – Mandrill API Example by Mike Doubintchik (@allurewebsolutions) on CodePen.

If you have any questions, please ask in the comments.

Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply