dce-send-email
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

dce-send-email

Simple email sender that easily integrates with Harvard DCE's AWS-based email service.

Usage

There is only one function that is exported:

import sendEmail from 'dce-send-email';

await sendEmail({
  to: 'my.friend@world.com',
  subject: 'Hi there!',
  body: 'Greetings!',
})

By default, the library will send the email from the address specified by the DEFAULT_SENDER_EMAIL environment variable.

You can also override it by passing in a senderEmail option:

await sendEmail({
  to: 'my.friend@harvard.edu',
  subject: 'Hi there!',
  body: 'Greetings!',
  senderEmail: 'my.email@harvard.edu',
})

The to argument can also be a list of addresses:

await sendEmail({
  to: [
    'my.friend@harvard.edu',
    'my.professor@harvard.edu',
  ],
  subject: 'Hi there!',
  body: 'Greetings!',
  senderEmail: 'my.email@harvard.edu',
})

You can also add CC or BCC recipients as a list of strings:

await sendEmail({
  to: [
    'my.friend@harvard.edu',
  ],
  cc: [
    'my.roommate@harvard.edu',
  ],
  bcc: [
    'my.professor@harvard.edu',
  ],
  subject: 'Hi there!',
  body: 'Greetings!',
  senderEmail: 'my.email@harvard.edu',
})

For more detailed messages, you can use HTML:

await sendEmail({
  to: 'my.friend@harvard.edu',
  subject: 'Hi there!',
  body: 'Greetings!',
  bodyHTML: '<h1>Greetings</h1><p>From Your Friends</p>',
  senderEmail: 'my.email@harvard.edu',
})

NOTE: if a recipients email client cannot render the HTML, it will fallback to rendering the pure text from body.

Contributors

Readme

Keywords

Package Sidebar

Install

npm i dce-send-email

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

21.7 kB

Total Files

13

Last publish

Collaborators

  • gabeabrams