This is the error message strapi shows:
error: Couldn’t send test email: Forbidden.
I have setup mailgun account and installed the @strapi/provider-email-mailgun plugin and configured the email settings in plugin.js.
This is how plugins.js look for email config.
domain: env("MAILGUN_DOMAIN"), //Required if you have an account with multiple domains
host: env("MAILGUN_HOST"), // we have only 2 options here. api.mailgun.net for US servers, api.eu.mailgun.net for EU Servers.
In the mailgun dashboard nothing happens. No logs is created.
Haha. I solved it.
I had put in a IP adress in the whitelist and it was wrong IP-address.
In my case, it is sending mails, but the mail is not coming to my mail, why?
How does your plugins.js email settings look like?
If you use Strapi 4 then it should look like this.
I’m using Strapi 3, what do I need to do on Mailgun to make it available to send messages?
I tested it with Authorized Recipients, but we cannot be all-time putting any new user to such a list!
I don’t know how to do it in Strapi 3. Didn’t use it to much. Jumped to version 4.
Ok, it does not matter.
For sending messages out of Authorized Recipients, do I need to use the upgrade tier? To choose a domain? Do we need to do all such shit to having it working?
I have the 3 month trial when I signed up for mailgun. You need to add a domain and follow their instructions with txt and mx, cname records.
Well, where choose the domain? I can’t find it.
First time I logged in to mailgun I was asked to add a domain. It was a step by step introduction for first time users. So I just followed that.
A quick google gave this result.
We got this answer:
I’m not sure I understand what you’re looking to do. Currently, on your account, you just have the sandbox domain that is included and you’re only allowed 5 Authorized recipients. So if you want to add more to that, you have to remove other recipients. Alternatively, if you own a domain, you can verify your domain through Mailgun so you can send messages using your custom domain. Below I’ve linked our documentation on adding your domain to Mailgun.
What it says is totally different what you say.
In my case, adding IP to Allow Listed IP Addresses isn’t working. I am using Strapi v4.15.4, Sendgrid, done Sender Authentication and this has been working only locally, not production.
Error: Couldn't send test email: Unauthorized.
at Object.test (/home/username/workspace/appname/node_modules/@strapi/plugin-email/dist/server/index.js:173:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async returnBodyMiddleware (/home/username/workspace/appname/node_modules/@strapi/strapi/dist/services/server/compose-endpoint.js:42:18)
at async policiesMiddleware (/home/username/workspace/appname/node_modules/@strapi/strapi/dist/services/server/policy.js:15:5)
at async /home/username/workspace/appname/node_modules/@strapi/strapi/dist/services/server/compose-endpoint.js:27:12
at async /home/username/workspace/appname/node_modules/@strapi/strapi/dist/middlewares/body.js:45:9
at async /home/username/workspace/appname/node_modules/@strapi/strapi/dist/middlewares/logger.js:6:5
at async /home/username/workspace/appname/node_modules/@strapi/strapi/dist/middlewares/powered-by.js:9:5
at async cors (/home/username/workspace/appname/node_modules/@koa/cors/index.js:107:16)
at async /home/username/workspace/appname/node_modules/@strapi/strapi/dist/middlewares/errors.js:8:7
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).