Coresender Logo Mobile menu icon
Blog/Product

How to send emails with Coresender API

In Coresender, you can send emails using our SMTP server or with the API. In general, sending via API will give you some more advanced features down the road. In this article, we'll help you send your first email with Coresender API.

Getting started

To send emails with Coresender, you will need your sending account created and your sending domain configured and verified. If you haven't done this already, please go to our Quickstart Start Guide and complete it first.

To communicate with the API, you will need a Sending account ID and an API key. Go to the Coresender control panel. Click on Sending accounts in the menu, and select one of your Sending accounts (you probably have one). On the details page you'll find your Sending account ID at the top and your API key in a "API keys" tab. Copy both strings, and you're ready to go.

Let's use curl to send the first email. Head out to our API documentation and take a look at the Send email API. You'll find a sample code that showcases all features of this API. For this example, let's use a minimalistic version, though:

POST/v1/send_emailClick to copyClick to copy
curl -X POST https://api.coresender.com/v1/send_email \
  -u 'account_id:api_key' \
  -d $'[
    {
      "from": {
        "email": "[email protected]",
        "name": "Jean-Luc Picard"
      },
      "to": [
        { 
          "email": "[email protected]",
          "name": "Geordi La Forge"
        }
      ],
      "subject": "I need engines",
      "body": {
        "text": "Geordi, I need engines, now!"
      }
    }
  ]'

Before running the code, replace account_id and api_key with the values you have obtained from the control panel. You also have to replace from.email with an email address within your verified sending domain. The to.email address can be any valid email address.

Let's run the code now and check the result:

API response
{
  "data": [{
    "message_id": "7dd8eab0-ceca-4335-8291-5caffe329ef6",
    "custom_id": "",
    "status": "accepted",
    "errors": []
  }],
  "meta": {
    "rq_time": "0.0243s"
  }
}

You can read a few things from the response:

  • The message got accepted without any errors
  • The message got its unique ID which you can use to search for it in the activity screen of our control panel
  • API request took 24ms to complete

Here's our email arriving at the recipient's inbox:

And here's the message timeline that you can find in Coresender's control panel:

Congratulations!

You have just sent your first email with Coresender API. What you can do next:

  • Explore our open source SDKs and start working on your integration. Remember that any standard HTTP library will allow you to integrate Coresender in any language, even if we don't provide an SDK.
  • Request your organization to be approved by Coresender so you can upgrade from the free developer plan and start using our service in your production environment.
Back to articles listBack to articles list

Try Coresender today

Whether you need to send a few hundred emails or a few million, we’re ready to help you deliver your message. Are you ready to get started?

Try for free