feat(notification-sendgrid): include ability to handle attachments (#8729)
* feat(notification-sendgrid): include ability to handle attachments array if passed to dynamicTemplateData.attachments * docs: update sendgrid page.mdx include attachments documentation in example * ability to set from email, must be verified sender * docs: update to include optional from property * first-class optional vars for from & attachments * docs: update for optional first-class vars * Update www/apps/resources/app/architectural-modules/notification/sendgrid/page.mdx Co-authored-by: Shahed Nasser <shahednasser@gmail.com> --------- Co-authored-by: Stevche Radevski <sradevski@live.com> Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
This commit is contained in:
co-authored by
Shahed Nasser
Stevche Radevski
parent
ac18b5d35f
commit
a430339d54
@@ -12,20 +12,22 @@ The SendGrid Notification Module Provider integrates [SendGrid](https://sendgrid
|
||||
|
||||
## Install the SendGrid Notification Module
|
||||
|
||||
<Prerequisites items={[
|
||||
{
|
||||
text: "SendGrid account",
|
||||
link: "https://signup.sendgrid.com"
|
||||
},
|
||||
{
|
||||
text: "Setup SendGrid single sender",
|
||||
link: "https://docs.sendgrid.com/ui/sending-email/sender-verification"
|
||||
},
|
||||
{
|
||||
text: "SendGrid API Key",
|
||||
link: "https://docs.sendgrid.com/ui/account-and-settings/api-keys"
|
||||
}
|
||||
]} />
|
||||
<Prerequisites
|
||||
items={[
|
||||
{
|
||||
text: "SendGrid account",
|
||||
link: "https://signup.sendgrid.com",
|
||||
},
|
||||
{
|
||||
text: "Setup SendGrid single sender",
|
||||
link: "https://docs.sendgrid.com/ui/sending-email/sender-verification",
|
||||
},
|
||||
{
|
||||
text: "SendGrid API Key",
|
||||
link: "https://docs.sendgrid.com/ui/account-and-settings/api-keys",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
To install the SendGrid Notification Module Provider, run the following command in the directory of your Medusa application:
|
||||
|
||||
@@ -154,9 +156,19 @@ export default async function productCreateHandler({
|
||||
|
||||
await notificationModuleService.createNotifications({
|
||||
to: "test@gmail.com",
|
||||
from: "test@medusajs.com", // Optional var, verified sender required
|
||||
channel: "email",
|
||||
template: "product-created",
|
||||
data,
|
||||
attachments: [ // optional var
|
||||
{
|
||||
content: base64,
|
||||
content_type: MIME type,
|
||||
filename: filename.ext,
|
||||
disposition: "attachment or inline attachment",
|
||||
id: "id", // only needed for inline attachment
|
||||
},
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -172,6 +184,8 @@ In this subscriber:
|
||||
- By specifying the `email` channel, the SendGrid Notification Module Provider is used to send the notification.
|
||||
- The `template` property of the `create` method's parameter specifies the ID of the template defined in SendGrid.
|
||||
- The `data` property allows you to pass data to the template in SendGrid.
|
||||
- The `attachments` optional property allows you to pass attachments to the template in SendGrid.
|
||||
- The `from` optional property allows you to pass a single sender-verified email. If not provided, the value of the `from` configuration of the module is used.
|
||||
|
||||
Then, start the Medusa application:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user