Configure Email Notifications¶
Virto Commerce Platform enables sending email notifications for various system events, such as restoring passwords, customer order processing, etc. To send such notifications, use a third-party email service provider by setting up an mail gateway so that the platform may start sending emails. Currently, there are two gateways options: SMTP and SendGrid.
Prerequisites¶
Configure SMTP email settings¶
To enable sending notifications through Gmail:
-
Turn on the Allow less secure apps option in Google Security Settings.
-
Edit the Notifications section in the appsettings.json file:
appsettings.json... "Notifications": { "Gateway": "Smtp", "DefaultSender": "[email protected]", //the default sender address "Smtp": { "SmtpServer": "http://smtp.gmail.com", "Port": 587, //TLS port "Login": "", //Your full Gmail address (e.g. [email protected]) "Password": "" //The password that you use to log in to Gmail }, }, ....
Warning
After modifying the appsettings.json file, restart the application to apply the changes.
Configure SendGrid email settings¶
To work with the SendGrid settings:
-
Register a SendGrid account according to this SendGrid article.
-
Edit the Notifications section in the appsettings.json file:
appsettings.json... "Notifications": { "Gateway": "SendGrid", "DefaultSender": "[email protected]", //the default sender address "SendGrid": { "ApiKey": "your API key", //SendGrid API key }, }, ....
Test notification sending process¶
To test your notifications, use REST Admin API queries that require a valid access token.
To test whether an email has been sent successfully:
-
Run the query:
curl -X POST "https://localhost:5001/api/notifications/send" -H "accept: text/plain" -H "Authorization: Bearer {access_token}" -H "Content-Type: application/json-patch+json" -d '{"type":"RemindUserNameEmailNotification","from":"[email protected]","to":"{your email}"}''
-
In case of success, you will receive an test email on your email account. Otherwise, go to Notifications → Notification activity feed to see which error(s) led to a failure: