Receive Emails: Send & trust

Send Email

Send a new email from the sender behind your token. The message is saved to Sent right away and delivered in the background.

POSThttps://g.sendcorex.com/v1command: send_email
i

queued: true means saved and waiting in the queue, not delivered. The message_id in the response is provisional: the real SMTP Message-ID replaces it a few seconds later and shows up in get_messages.

!

Attachments are not supported yet. The body is limited to 2 MB. cc and bcc are accepted but are not active in the beta version.

Arguments

  • tostringrequired

    Recipient email address. One address.

  • to_namestringoptional

    Recipient name. Defaults to the part before the @.

  • subjectstringrequired

    Email subject.

  • htmlstringoptional

    HTML body. Send html or text.

  • textstringoptional

    Plain text body. It is converted to HTML with <br>.

  • ccstring[]optional

    Up to 50 addresses. Not active in the beta version.

  • bccstring[]optional

    Up to 50 addresses. Not active in the beta version.

  • labelstringoptional

    A label to put on the sent message. It becomes labels: [label].

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "send_email",
        args: {
          to: "client@example.com",
          to_name: "Client",
          subject: "Quote",
          html: "<p>Here is the quote.</p>",
          label: "sales"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);

Response

{
  "type": "SUCCESS",
  "results": [
    {
      "command": "send_email",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "message_uid": "Vj0xQUJDMTIz",
        "thread_id": "thr_9a1c4e72",
        "message_id": "<5e0b9c1a-3d7f-4a21-9a6e-2f1c8d4b7e90>",
        "queued": true
      }
    }
  ]
}

Response fields

  • message_uid

    The id of the sent message. It appears in Sent immediately.

  • thread_id

    The conversation of the new message.

  • message_id

    A provisional Message-ID. The real SMTP one replaces it shortly after.

  • queued

    true = saved and queued for delivery. It does not mean delivered.

Repeated sends

The same write (same args) repeated within 1.5 seconds returns the first result instead of sending again. A polling loop that sends the same email twice does not duplicate it.

Errors

HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.

  • 401TOKEN_EXPIRED

    The access token has expired. Call Refresh Token and repeat the request.

  • 401INVALID_TOKEN

    The token is malformed, unknown or revoked.

  • 429RATE_LIMITED

    More than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.

  • CMDINVALID_ARGS

    A required argument is missing or invalid.

  • CMDNO_CREDITS

    The account has no email credits left.

  • CMDSENDER_NOT_FOUND

    The sender behind the token is not registered.

  • CMDSENDER_NO_DOMAIN

    The sender behind the token has no domain.

  • CMDINTERNAL

    Server error. The detail is only written to the server log.