SendGrid is a popular email API provider which allows you to easily setup a email service. The SendGridMail
connection can be used to connect to an existing SendGrid API account.
The SendGridMail
connector uses the @sendgrid/mail library.
In order to use the SendGridMail
connector, you first need to create a SendGrid account and setup an API key.
Secrets like API keys should be stored using the
_secret
operator.
In order to send from your custom domain your will need to authenticate your domain through SendGrid. See the SendGrid Docs for help on getting started with SendGrid.
Connections
Connection types:
- SendGridMail
Requests
Request types:
- SendGridMailSend
Types
email: string | object
: SendGrid accepts emails as either astring
or anobject
.string
: Can be in the following format;someone@example.org
orSome One <someone@example.org>
.object
: Withname' and
emailproperties, for example:
{"name": "Some One", "email": "someone@example.org"}`.
SendGridMail
Properties
apiKey: string
: Required - SendGrid API key.from: email
: Required - Email address to send email from.mailSettings: object
: SendGrid mail settings. See SendGrid API-ReferencesandboxMode: object
: SendGrid mail sandbox mode settings.enable: boolean
: Sandbox mode enabled whentrue
.
templateId: string
: SendGrid email template ID to render email when sending.
SendGridMailSend
Properties
object
A mail description
:
to: email | email[]
: Required - Email address or addresses to send to.cc: email | email[]
: Email address to cc in communication.bcc: email | email[]
: Email address to bcc in communication.replyTo: email | email[]
: Email address to reply to.subject: string
: Email subject.text: string
: Email message in plain text format.html: string
: Email message in html format.dynamicTemplateData: object
: SendGrid template data to render into email template.sendAt: integer
: A unix timestamp allowing you to specify when you want your email to be delivered. You can't schedule more than 72 hours in advance.attachments: object[]
: List of email attachments to include with email. See SendGrid API-Reference.content: string
: Required - Base 64 encoded attachment content.filename: string
: Required - Name of the attachment file.type: string
: The mime type of the content you are attaching. For example,text/plain
ortext/html
.
array
An array of mail description
objects can also be provided.
Examples
Send a reminder email
connections:
- id: my_sendgrid
type: SendGridMail
properties:
apiKey:
_secret: SENDGRID_API_KEY
from: reminders@example.org
# ...
requests:
- id: send_reminder
type: SendGridMailSend
connectionId: my_sendgrid
properties:
to: Harry Potter <harry@example.org>
subject: Reminder for Mr. Potter to water the 🌱
text: |
Hi Harry
Please remember to water the magic plants today :)
Thank you
# ...