A module to simplify the connection to sendgrid for sending mail
- Source
Methods
(static) init(apiKey, from)
Initialize the Sendgrid module
Parameters:
Name | Type | Description |
---|---|---|
apiKey | String | Api key from sendgrid. |
from | String | Standard from email address that will be used also as standard replyTo. |
- Since
- 1.0.0
- Copyright
- MIT
- Source
Example
const {Runtime, Server} = require('@neobeach/core');
const sendgrid = require('@neobeach/modules-sendgrid')
const server = new Server();
Runtime(() => {
sendgrid.init(sendgridApiKey, 'noreply@dpdk.com');
server.run();
});
(static) send(to, subject, text, html, replyToopt, ccopt, bccopt, attachmentsopt) → {Promise}
Helper function to send email with Sendgrid.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
to | Array.<string> | | String with email to send to or an array filled with email addresses the email will be sent to. | |
subject | String | Subject of the email. | |
text | String | Text of the body of the mail. | |
html | String | Body of email in html. | |
replyTo | String | <optional> | Email address where replies to send email will be sent to (default from email). |
cc | Array.<string> | | <optional> | String with email to send to or an array filled with email addresses the email will be sent to. |
bcc | Array.<string> | | <optional> | String with email to send to or an array filled with email addresses the email hidden will be sent to. |
attachments | Array | <optional> | Array filled with needed object attachments information. |
- Since
- 1.0.0
- Copyright
- MIT
- Source
Returns:
- Type:
- Promise
Example
const sendGrid = require('@neobeach/modules-sendgrid');
const response = await sendGrid.send({
to: 'user@example.com',
subject: 'Testing mail',
text: 'This is a testing mail',
html: '<p>This is a testing mail</p>',
replyTo: 'replyToUser@example.com',
cc: 'anotheruser@example.com',
bcc: 'hiddenuser@example.com,
attachments: []
}}