dce-send-email
v1.0.1
Published
Simple email sender that easily integrates with Harvard DCE's AWS-based email service
Downloads
19
Readme
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: '[email protected]',
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: '[email protected]',
subject: 'Hi there!',
body: 'Greetings!',
senderEmail: '[email protected]',
})
The to
argument can also be a list of addresses:
await sendEmail({
to: [
'[email protected]',
'[email protected]',
],
subject: 'Hi there!',
body: 'Greetings!',
senderEmail: '[email protected]',
})
You can also add CC or BCC recipients as a list of strings:
await sendEmail({
to: [
'[email protected]',
],
cc: [
'[email protected]',
],
bcc: [
'[email protected]',
],
subject: 'Hi there!',
body: 'Greetings!',
senderEmail: '[email protected]',
})
For more detailed messages, you can use HTML:
await sendEmail({
to: '[email protected]',
subject: 'Hi there!',
body: 'Greetings!',
bodyHTML: '<h1>Greetings</h1><p>From Your Friends</p>',
senderEmail: '[email protected]',
})
NOTE: if a recipients email client cannot render the HTML, it will fallback to rendering the pure text from body
.