Skip to content

Sending Email

Sending Email

All API requests should start with the following base part:

Base URL

All API requests should start with the following base URL:

http
https://api.seamailer.app/v1.0/
sh
curl - X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
https://api.seamailer.app/v1.0/connect/v1.0/email/send \
-H "Content-Type: application/json" \
-d '{
"from": "mycompany@email.com",
  "to": [
    {
      "email": "user@gmail.com",
      "name": "userName"
    }
  ],
  "subject": "Hello World",
  "htmlPart": "<p>Hi there</p>"
  // ... add more variables as needed
  }'
js
import { SeaMailerClient } from "seamailer";

const SeaMailer = new SeaMailerClient(`api key`);

SeaMailer.sendMail({
  from: "mycompany@email.com",
  to: [
    {
      email: "user@email.com",
      name: "user_name",
    },
  ],
  subject: "Hello World",
  htmlPart: "<p>Hi there</p>",
  // ... add more variables as needed
});

Leveraging templates to send email

All API requests should start with the following base part:

sh
curl - X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
https://api.seamailer.app/v1.0/connect/v1.0/email/send \
-H "Content-Type: application/json" \
-d '{
"from": "mycompany@email.com",
  "to": [
    {
      "email": "user@gmail.com",
      "name": "userName"
    }
  ],
  "subject": "Hello World",
  "templateId": "template_id_goes_here",
  "variables": {
    "name": "user_name"
  }
  // ... add more variables as needed
  }'
js
import { SeaMailerClient } from "seamailer";

const SeaMailer = new SeaMailerClient(`api key`);

SeaMailer.sendMail({
  from: "mycompany@email.com",
  to: [
    {
      email: "user@email.com",
      name: "user_name",
    },
  ],
  subject: "Hello World",
  templateId: "template_id_goes_here",
  variables: {
    name: "user_name",
  },
  // ... add more variables as needed
});

Request Header

To send an email, you will need to send a payload to your request and below are the params that can be used

ParamsRequiredDescription
AuthorizationYesThe token used for authorization can be retreive in settings, api keys.
Content-Typeapplication/jsonSpecifies the media type of the request body

Header example

sh
curl - X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
https://api.seamailer.app/v1.0/connect/v1.0/email/send \
-H "Content-Type: application/json"

Request Payload

To send an email, you will need to send a payload to your request and below are the params that can be used

ParamsRequiredDescription
fromYesThe sender information
toYesThe receiver information
ccNoCarbon Copy (Send a copy of email to additional recipient with the recipient aware and also appear in header and can reply)
bccNoBlind Carbon Copy (Send a copy of email to additional recipient without the primary recipient aware, and also does not appear in header and cannot reply)
replyToNoThis is an address that receives replies to an email that is different from "From"
subjectYesSubject of the email
textPartNoSend a plain text in email
htmlPartNoSend raw html code in email to be rendered
templateIdNoUse a template by the template id instead of passing a raw html code
templateLanguageNoThe language the template is using
variablesNoThe variables for the template which consists of the values
priorityNoPriority of the email
attachmentsNoIs a file that is sent along with an email message
inlinedAttachmentsNoFiles that are part of the email's HTML body and are displayed in the body of the message.

Request body example

sh
curl - X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
https://api.seamailer.app/v1.0/connect/v1.0/email/send \
-H "Content-Type: application/json" \
-d '{
  "from": "mycompany@email.com",
  "to": [
    {
      "email": "user@gmail.com",
      "name": "userName"
    }
  ],
  "cc": [
    {
      "email": "user@gmail.com",
      "name": "userName"
    }
  ],
  "bcc": [
    {
      "email": "user@gmail.com",
      "name": "userName"
    }
  ],
   "replyTo": {
      "email": "user@gmail.com",
      "name": "userName"
  },
  "subject": "Hello World",
  "textPart": "<p>Hi there</p>",
  "htmlPart": "<p>Hi there</p>",
  "templateId": "template_id_goes_here",
  "templateLanguage": "",
  "variables": {
    "name": "user_name"
  },
  "priority": 1,
  "attachments": [
    {
      "filename": "seamailer",
      "contentType": "pdf",
      "base64Content": "sdfsdf3rewfedc3blabla"
    }
  ],
   "inlinedAttachments": [
    {
      "filename": "seamailer",
      "contentType": "pdf",
      "base64Content": "sdfsdf3rewfedc3blabla"
    }
  ]
}'

Response Payload

After sending an email, the server responds back with a payload

ParamsRequiredDescription
fromYesThe sender information

Response body example

json
{
}

HTTP response codes

Status CodeDescription
200Success, everything went smoothly
400Bad Request
401Unauthorized Missing or incorrect API token
500Internal Server Error