imago-sendemail
v2.1.0
Published
A simple utility to send email using the Amazon SES.
Downloads
9
Readme
Imago Send Email
A simple utility for sending emails via the Amazon SES.
To use it, you need to first sign up for AWS and Simple Email Service there, set up a domain, and generate credentials (not SMTP credentials - the other type of credentials, that include access key ID and secret access key). More details: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/using-credentials.html
Setting up variables
- Set environment variable
AWS_REGION
(e.g. tous-east-1
). - Set environment variables
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
to your Amazon credentials created using IAM. - Set environment variable SENDER_EMAIL_ADDRESS to your Amazon-approved email address. This will show in the From field of all emails.
Setting up code
Install this package:
npm i --save imago-sendemail
Run the code with these options:
const Sender = require('imago-sendemail');
let sender = new Sender({
to: '[email protected]',
cc: '[email protected]', // optional
bcc: '[email protected]', // optional
subject: 'Hey there',
body: {
html: '<h1>HTML text of your email</h1>',
text: 'Plaintext of your email',
},
});
await sender.send();
It is better to wrap the .send()
in a try-catch because it will throw an
exception in case of any error.
There are no other options except as shown above.