Receive Emails: Drafts

Send Draft

Send a saved draft now, through the same checks as send_email, reply and forward.

POSThttps://g.sendcorex.com/v1command: send_draft
!

This really sends the email. Credits, the daily limit and the anti-spam check run like in any other send.

i

The draft is deleted only after the send is accepted. If the send is refused, the draft stays in Drafts and the error message ends with "The draft was kept."

i

A forward draft goes with the "Forwarded message" block of the original. If the body already has the block (drafts written in the webmail), it is not added twice.

Arguments

  • idstringrequired

    The draft_id.

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "send_draft",
        args: {
          id: "Vj0xRFJBRlQx"
        }
      }
    ]
  },
  { 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_draft",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "message_uid": "Vj0xQUJDMTIz",
        "thread_id": "thr_9a1c4e72",
        "message_id": "5e0b9c1a-3d7f-4a21-9a6e-2f1c8d4b7e90",
        "recipients": 1,
        "queued": true
      }
    }
  ]
}

Response fields

  • message_uid

    The sent email, now in Sent. Same result as send_email.

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.

  • CMDRECIPIENT_UNSUBSCRIBED

    One or more recipients unsubscribed from this mailbox. `recipients` lists them: remove them or send again with `unsubscribe: false`.

  • CMDINVALID_ARGS

    A required argument is missing or invalid.

  • CMDDRAFT_NOT_FOUND

    The draft does not exist anymore: it was sent, deleted, or saved again (every save returns a new draft_id).

  • CMDINVALID_RECIPIENT

    The recipient is missing or not a valid email.

  • CMDMISSING_SUBJECT

    A new email needs a subject.

  • CMDMISSING_TARGET

    Reply and forward need the original email, and it must still exist.

  • CMDRECIPIENT_LIMIT_EXCEEDED

    to, cc and bcc together have more than 50 addresses.

  • CMDATTACHMENT_MISSING

    An uploaded attachment no longer exists (uploads not sent within 48 hours, and not used by a draft or scheduled email, are deleted). Upload it again.

  • CMDNO_CREDITS

    The account has fewer email credits than recipients (1 credit per copy).

  • 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.