
Security News
TypeScript Native Previews: 10x Faster Compiler Now on npm for Public Testing
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.
@netlify/plugin-emails
Advanced tools
A build plugin that creates an email handler and processes requests to send emails
🚧 Note: This plugin is pre-release software. Until version 1.0.0 is released, its API could change at any time.
The Netlify emails build plugin is responsible for creating a serverless function to handle email requests, using the email request to populate provided email templates and sending them using the specified email API provider.
Full documentation for the Netlify Email Integration can be found here.
You must setup an account with one of our supported email providers listed above. You will also need to ensure your account is verified by the email provider and you have provided authorisation for emails to be sent from any email address you send from.
Add it to your site via the Netlify app under Integrations - (app.netlify.com/integrations/{your-sitename}/emails).
When enabling the plugin via Integrations, you should add the required configuration variables to complete the configuration step.
Now that the setup is complete, create an email directory ./emails
(default) or use a custom directory, as long as you define it in your Email Settings under ‘Template directory’.
Each email template should be stored under a folder name that represents the route of your template and the email file should be named index.html
. E.g. ./emails/welcome/index.html
.
If there are variables that need replacing in your email template when the email is triggered, please use the handlebars.js syntax and pass the arguments in the request as shown in Step 5 below.
Sample email with parameters:
<html>
<body>
<h1>Welcome, {{name}}</h1>
<p>We hope you enjoy our super simple emails!</p>
</body>
</html>
Visit http://localhost:{PORT}/.netlify/functions/emails/_preview
to preview your email templates.
Please note, this preview endpoint is not made available in production and is only made available locally.
Dependent on where you would like to trigger an email being sent (on a subscribe or data request button click, when an event is triggered, etc.), add this snippet to your code that is reacting to that event.
import fetch from 'node-fetch'
await fetch(
`${process.env.URL}/.netlify/functions/emails/welcome`,
{
headers: {
"netlify-emails-secret": process.env.NETLIFY_EMAILS_SECRET,
},
method: "POST",
body: JSON.stringify({
from: "no-reply@yourdomain.com",
to: "alexanderhamilton@test.com",
cc: "cc@test.com",
bcc: "bcc@test.com",
subject: "Welcome",
parameters: {
products: ["product1", "product2", "product3"],
name: "Alexander",
},
}),
}
);
You can also trigger the email locally by running netlify build
, then netlify dev
and making the above request.
FAQs
A build plugin that creates an email handler and processes requests to send emails
The npm package @netlify/plugin-emails receives a total of 1,221 weekly downloads. As such, @netlify/plugin-emails popularity was classified as popular.
We found that @netlify/plugin-emails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.
Research
Security News
Malicious npm packages targeting React, Vue, Vite, Node.js, and Quill remained undetected for two years while deploying destructive payloads.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.