npm install @boklisten/bl-email
npm version # Optionally --patch
npm publish
NB: Do not use yarn publish
!
import the emailHandler
import { EmailHandler } from "@boklisten/bl-email";
create a emailHandler (the emailTemplateConfig will be discussed later)
const emailHandler = new EmailHandler(emailTemplateConfig);
send an email
emailHandler.send({
userId: "user1",
toEmail: "wizard@boklisten.com",
fromEmail: "noreply@email.com",
subject: "Hi there",
emailType: "hello",
});
The emailHandler supports different types of emails tailored for use with boklisten.no apps.
let emailTemplateInput = {
emailType: "the email type",
userId: "the id of the user this mail is regarding",
toEmail: "user@email.com",
fromEmail: "noreply@email.com",
subject: "a subject for the email",
};
Used as a welcome message when the customer registers.
let emailTemplateInput = {
emailType: "hello",
};
A generic email that can take display messages specified by the user.
let emailTemplateInput = {
emailType: "generic",
title: "a title for the message",
textBlocks: [
{
text: "a user created message, can have as many textBlocks as the user wants",
},
],
};
A email that is sent out for the customer to confirm his or her email address
let emailTemplateInput = {
emailType: "confirm-email",
confirmLink: "a https link for the user to confirm email",
};
A email that is sent out if the customer requests a password reset
let emailTemplateInput = {
emailType: "password-reset",
passwordResetLink: "a https link for the user to reset his or her password",
};
A email that is sent when a order has been processed, this can for ex. be an order, some deliveries or extends.
let emailTemplateInput = {
emailType: "receipt",
username: "the name of the user",
showPrice: true || false,
showDeadline: true || false,
numberOfCols: 3,
items: [
{
title: "the title of the item",
status: "ordered",
deadline: "the deadline date",
price: 100,
},
],
totalPrice: 100,
order: {
orderId: "id of order",
},
};