Sendlayer API utilities.
npm install @yiaoma/sendlayer-utils
- You need a Sendlayer API key. Set it as an environment variable named
SENDLAYER_API_KEY
.
import { sendEmail } from "@yiaoma/sendlayer-utils";
await sendEmail({
From: {
name: "Paulie Paloma",
email: "[email protected]",
},
To: [
{
name: "Pattie Paloma",
email: "[email protected]",
},
],
CC: [
{
name: "Pattie Paloma CC",
email: "[email protected]",
},
],
BCC: [
{
name: "Pattie Paloma BCC",
email: "[email protected]",
},
],
ReplyTo: [
{
name: "Pattie Paloma ReplyTo",
email: "[email protected]",
},
],
Subject: "This is the email subject",
ContentType: "HTML",
HTMLContent: "<html><body><p>This is a test email!</p></body></html>",
Tags: ["newsletter, daily"],
Headers: {
"X-Mailer": "test mailer",
"X-Test": "test header",
},
Attachments: [
{
Content: "BASE 64 ENCODED STRING",
Type: "image/png",
Filename: "test.png",
Disposition: "attachment",
ContentId: "0",
},
],
});
import { getEvents } from "@yiaoma/sendlayer-utils";
await getEvents({
StartDate: 1646901478,
EndDate: 1646901480,
Event: "delivered",
StartFrom: 0,
RetrieveCount: 20,
MessageID: "10210a3d-7d37-4967-9c20-ad4e26016a78",
});
import { getWebhooks } from "@yiaoma/sendlayer-utils";
await getWebhooks();
import { createWebhook } from "@yiaoma/sendlayer-utils";
await createWebhook({
Event: "delivery",
WebhookURL: "www.example.com",
});
import { deleteWebhook } from "@yiaoma/sendlayer-utils";
await deleteWebhook({
WebhookID: 972,
});
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.