SendGrid transactional emails
npm install medusa-plugin-sendgridHandle sending emails to customers related to orders, restock notifications, users, or custom events.
SendGrid Plugin Documentation | Medusa Website | Medusa Repository
- Send emails when an event related to orders, restock notifications, or users is triggered.
- Use dynamic templates in SendGrid to build the emails to be sent.
- Send emails with SendGrid for custom events.
---
- Medusa backend
- SendGrid account
---
1\. Run the following command in the directory of the Medusa backend:
``bash`
npm install medusa-plugin-sendgrid
2\. Set the following environment variable in .env:
`bash`
SENDGRID_API_KEY=
SENDGRID_FROM=
# IDs for different email templates
SENDGRID_ORDER_PLACED_ID=
3\. In medusa-config.js add the following at the end of the plugins array:
`jsmedusa-plugin-sendgrid
const plugins = [
// ...,
{
resolve: ,`
options: {
api_key: process.env.SENDGRID_API_KEY,
from: process.env.SENDGRID_FROM,
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID,
localization: {
"de-DE": { // locale key
order_placed_template:
process.env.SENDGRID_ORDER_PLACED_ID_LOCALIZED,
},
},
},
},
]
---
1\. Run the following command in the directory of the Medusa backend to run the backend:
`bash``
npm run start
2\. Place an order using a storefront or the Store APIs. You should receive a confirmation email.
---