Prerequisites
To get the most out of this guide, you’ll need to:1. Install
Get the Emailr Node.js SDK.2. Send email using HTML
html parameter.
api/src/functions/send/send.ts
3. Try it yourself
Redwood.js Example
See the full source code.
Learn how to send your first email using Redwood.js and the Emailr Node.js SDK.
yarn workspace api add emailr
yarn rw g function send
html parameter.
import { Emailr } from 'emailr';
import type { APIGatewayEvent, Context } from 'aws-lambda';
const emailr = new Emailr('em_xxxxxxxxx');
export const handler = async (event: APIGatewayEvent, context: Context) => {
const { data, error } = await emailr.emails.send({
from: 'Acme <[email protected]>',
to: ['[email protected]'],
subject: 'hello world',
html: '<strong>it works!</strong>',
});
if (error) {
return {
statusCode: 500,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ error }),
};
}
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ data }),
};
};