Receive Emails: Routes
Raw Message
Download the raw .eml of a message or one of its attachments as binary data.
https://g.sendcorex.com/v1/rawMessage ids are base64, so they contain +, / and =. URL-encode them. HTTP libraries do this for you when you pass them as query parameters, as in the examples below.
Attachments are always served as attachment with application/octet-stream. The original type is in the X-Original-Content-Type response header. Treat attachments as untrusted files.
Query parameters
message_idstringrequiredThe
message_uidof the message.attachment_idstringoptionalThe
attachment_idreturned byget_messages. When set, the attachment is returned instead of the whole email.
Quick start
import axios from 'axios';
import { writeFileSync } from 'node:fs';
const response = await axios.get('https://g.sendcorex.com/v1/raw', {
params: { message_id: 'Vj0xQUJDMTIz', attachment_id: 'Vj0xQVRUMDE' },
headers: { Authorization: process.env.SENDCOREX_TOKEN },
responseType: 'arraybuffer',
});
writeFileSync('attachment.bin', Buffer.from(response.data));Response
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment
X-Original-Content-Type: application/pdf
<binary data>Response fields
Content-Typemessage/rfc822for the raw email, orapplication/octet-streamfor an attachment.X-Original-Content-TypeThe real MIME type of the attachment, such as
application/pdf.
Download the whole email
Leave out attachment_id to get the original message as an .eml file.
Node.js
import axios from 'axios';
import { writeFileSync } from 'node:fs';
const res = await axios.get('https://g.sendcorex.com/v1/raw', {
params: { message_id: 'Vj0xQUJDMTIz' },
headers: { Authorization: process.env.SENDCOREX_TOKEN },
responseType: 'arraybuffer',
});
writeFileSync('message.eml', Buffer.from(res.data));Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
MISSING_AUTH_HEADERNo Authorization header was sent.
- 401
INVALID_TOKENThe token is malformed, unknown or revoked.
- 401
TOKEN_EXPIREDThe access token has expired. Call Refresh Token and repeat the request.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.