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

1.0.0 • 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({
  toAddress: '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({
  toAddress: 'my.friend@harvard.edu',
  subject: 'Hi there!',
  body: 'Greetings!',
  senderEmail: 'my.email@harvard.edu',
})

The toAddress argument can also be a list of addresses:

await sendEmail({
  toAddress: [
    '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({
  toAddress: [
    'my.friend@harvard.edu',
  ],
  ccAddresses: [
    'my.roommate@harvard.edu',
  ],
  bccAddresses: [
    'my.professor@harvard.edu',
  ],
  subject: 'Hi there!',
  body: 'Greetings!',
  senderEmail: 'my.email@harvard.edu',
})

For more detailed messages, you can use HTML:

await sendEmail({
  toAddress: '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

0

Version

1.0.0

License

MIT

Unpacked Size

17.8 kB

Total Files

9

Last publish

Collaborators

  • gabeabrams