@thestartupfactory/open-snail
v1.0.2
Published
This library offers some reusability around transactional email, with (basic) integrations to Sendgrid and Postmark. Using it with a local config {@link LocalConfig} allows you store emails locally during development and see the values that would be sent
Readme
open-snail
This library offers some reusability around transactional email, with (basic) integrations to Sendgrid and Postmark. Using it with a local config {@link LocalConfig} allows you store emails locally during development and see the values that would be sent with the template in the console.
Example Usage With Sendgrid
const config: LiveConfig<{ testing: { name: string } }> = {
type: 'sendgrid',
from: '[email protected]',
apiKey: 'SG.asdfeasdfawefasdfawefasdfawefasdf'
templateLookup: { testing: 'd-8d73df1f54484982b061908fe20e8e06' }, // <--- Map internal names to template IDs
};
const client = GetClient(config);
await client.sendMail('testing', {
to: '[email protected]',
templateValues: { name: 'WORLD!' },
})Example usage with PostMark
const config: LiveConfig<{ testing: { name: string } }> = {
type: 'postmark',
from: '[email protected]',
apiKey: '7ec31028-34d2-4f12-b004-267ceedff957', // <--- Api key for your Postmark Server
templateLookup: { testing: 'testing' }, // <--- A map of template names to template aliases on your Postmark server
};
const client = GetClient(config);
await client.sendMail('testing', {
to: '[email protected]',
templateValues: { name: 'WORLD!' },
});Building
Run nx build open-snail to build the library.
Running unit tests
Run nx test open-snail to execute the unit tests via Jest.
