Skip to content

Instantly share code, notes, and snippets.

@DPLATA
Last active February 10, 2023 22:55
Show Gist options
  • Save DPLATA/057433835117401d4c57e96c9b402cc8 to your computer and use it in GitHub Desktop.
Save DPLATA/057433835117401d4c57e96c9b402cc8 to your computer and use it in GitHub Desktop.
netlify functions: sendEmail
POSTMARK_API_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
[build]
functions = "functions"
[[plugins]]
package = "@netlify/plugin-emails"
const { POSTMARK_API_KEY } = process.env
const serverToken = POSTMARK_API_KEY
let postmark = require("postmark")
let client = new postmark.ServerClient(serverToken);
exports.handler = (event, context, callback) => {
client.sendEmail(
{
From: "yourname@youremail.com",
To: "recipient@anotheremail.com",
Subject: "test email",
HtmlBody: "test",
TextBody: "test"
}
)
callback(null, {
statusCode: 200,
body: 'I am on my way !'
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment