1.0.1 • Published 1 year ago
dce-send-email v1.0.1
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.