opened 08:04AM - 04 Jun 20 UTC
closed 10:11AM - 09 Jun 20 UTC
**Describe the bug**
Email plugin is not working and I am getting errors while … sending the email. I have tried with multiple providers like Sendgrid, mailgun and mailtrap etc and same issue is coming.
I have followed the following link to do the setup:
https://strapi.io/documentation/v3.x/plugins/email.html#programmatic-usage
This is the error log on Strapi console:
```
AssertionError [ERR_ASSERTION]: Cannot wrap non-Error object
at new AssertionError (internal/assert.js:396:11)
at Object.exports.assert (/Users/Jay/Desktop/Temp/StrapiTemp1/my-project/node_modules/hoek/lib/index.js:559:11)
at Function.boomify (/Users/Jay/Desktop/Temp/StrapiTemp1/my-project/node_modules/boom/lib/index.js:107:14)
at formatBoomPayload (/Users/Jay/Desktop/Temp/StrapiTemp1/my-project/node_modules/strapi/lib/middlewares/boom/index.js:47:22)
at strapi.app.use (/Users/Jay/Desktop/Temp/StrapiTemp1/my-project/node_modules/strapi/lib/middlewares/boom/index.js:84:36)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
```
These are the setups, I have used in config/plugins.js:
```js
module.exports = ({ env }) => ({
email: {
provider: 'sendgrid',
providerOptions: {
apiKey: env('API_KEY'),
},
settings: {
defaultFrom: 'mrityunjay.tiwari@awrostamani.com',
defaultReplyTo: 'mrityunjay.tiwari@awrostamani.com',
},
},
});
```
**Steps to reproduce the behavior**
1. Install the new default Strapi project:
`yarn create strapi-app my-project --quickstart`
2. add the sendgrid package:
`yarn add strapi-provider-email-sendgrid --save`
3. add plugins.js under config folder with the following setup:
```js
module.exports = ({ env }) => ({
email: {
provider: 'sendgrid',
providerOptions: {
apiKey: env('API_KEY'),
},
settings: {
defaultFrom: 'mrityunjay.tiwari@awrostamani.com',
defaultReplyTo: 'mrityunjay.tiwari@awrostamani.com',
},
},
});
```
yarn develop and try to send the mail from postman using the following service:
`http://localhost:1337/email`
```json
{
"to": "jay01011986@gmail.com",
"subject": "Comment posted that contains a appriciations",
"text": "testing"
}
```
**Expected behavior**
A mail should be triggered.
**System**
- Node.js version: 13.12.0
- NPM version: 0.34.0
- Strapi version: 3.0.1
- Database: mssql
- Operating system: MacOS Catalina
this solution is working for my case with previous error messages for all environments. I have explicitly set Sendgrid API key with double quotes string in config/plugins.js rather than get it from an environment variable (in that case, it will be only working on local).