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
Params | Required | Description |
---|---|---|
Authorization | Yes | The token used for authorization can be retreive in settings, api keys. |
Content-Type | application/json | Specifies 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
Params | Required | Description |
---|---|---|
from | Yes | The sender information |
to | Yes | The receiver information |
cc | No | Carbon Copy (Send a copy of email to additional recipient with the recipient aware and also appear in header and can reply) |
bcc | No | Blind 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) |
replyTo | No | This is an address that receives replies to an email that is different from "From" |
subject | Yes | Subject of the email |
textPart | No | Send a plain text in email |
htmlPart | No | Send raw html code in email to be rendered |
templateId | No | Use a template by the template id instead of passing a raw html code |
templateLanguage | No | The language the template is using |
variables | No | The variables for the template which consists of the values |
priority | No | Priority of the email |
attachments | No | Is a file that is sent along with an email message |
inlinedAttachments | No | Files 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
Params | Required | Description |
---|---|---|
from | Yes | The sender information |
Response body example
json
{
}
HTTP response codes
Status Code | Description |
---|---|
200 | Success, everything went smoothly |
400 | Bad Request |
401 | Unauthorized Missing or incorrect API token |
500 | Internal Server Error |