2.1.0 • Published 5 years ago

imago-sendemail v2.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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

  1. Set environment variable AWS_REGION (e.g. to us-east-1).
  2. Set environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to your Amazon credentials created using IAM.
  3. 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: 'example@example.com',
  cc: 'someone.else@example.com', // optional
  bcc: 'secret@example.com', // 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.