@eucalyptusvc/sendgrid
This is a dedicated module for interaction with the mail endpoint of the Sendgrid v3 API.
Install
With yarn:
yarn add @eucalyptusvc/sendgrid
With npm:
npm install @eucalyptusvc/sendgrid
Usage
import { Sendgrid } from '@eucalyptusvc/sendgrid';
const mailer = new Sendgrid({
brand: 'Pilot',
apiKey: process.env.SENDGRID_API_KEY,
email: 'gday@pilot.com.au',
});
const data = {
email: 'hello@eucalyptus.vc',
templateId: 'd-xxxxxxxxxxxxxxxx',
variables: {
action_url: 'https://eucalyptus.vc',
firstName: 'Thomas',
},
};
(async (): Promise<void> => {
try {
await mailer.send({
to: data.email,
templateId: data.templateId,
variables: {
...data.variables,
},
});
} catch (error) {
console.error(error.message);
}
})();
Development
- Install dependencies using
yarn install
or npm install
- Start development server using
yarn watch