@upyo/sendgrid
v0.6.0
Published
SendGrid transport for Upyo email library
Maintainers
Readme
@upyo/sendgrid
SendGrid transport for the Upyo email library.
Installation
npm add @upyo/core @upyo/sendgrid
pnpm add @upyo/core @upyo/sendgrid
yarn add @upyo/core @upyo/sendgrid
deno add --jsr @upyo/core @upyo/sendgrid
bun add @upyo/core @upyo/sendgridUsage
import { createMessage } from "@upyo/core";
import { SendGridTransport } from "@upyo/sendgrid";
import fs from "node:fs/promises";
import process from "node:process";
const message = createMessage({
from: "[email protected]",
to: "[email protected]",
subject: "Hello from Upyo!",
content: { text: "This is a test email." },
attachments: [
new File(
[await fs.readFile("image.jpg"), "image.jpg", { type: "image/jpeg" }]
)
],
});
const transport = new SendGridTransport({
apiKey: process.env.SENDGRID_API_KEY!,
});
const receipt = await transport.send(message);
if (receipt.successful) {
console.log("Message sent with ID:", receipt.messageId);
} else {
console.error("Send failed:", receipt.errorMessages.join(", "));
}Configuration
See the SendGrid docs for more information about configuration options.
Available Options
apiKey: Your SendGrid API key (starts withSG.)baseUrl: SendGrid API base URL (default:https://api.sendgrid.com/v3)timeout: Request timeout in milliseconds (default: 30000)retries: Number of retry attempts (default: 3)clickTracking: Enable click tracking (default: true)openTracking: Enable open tracking (default: true)subscriptionTracking: Enable subscription tracking (default: false)googleAnalytics: Enable Google Analytics tracking (default: false)
