Email plugin from own gmail address

i’m trying to setup an email system for password confirmation and such.

the default strapi plugin isn’t supported on gmail, yahoo etc, does anyone have an up-to-date idiot-proof tutorial that explains in details how to setup such an email system on strapi, using one’s personal gmail as the sender?

thank you!!

you need Nodmailer
and your config:

module.exports = ({ env }) => ({
  // ...
  email: {
    config: {
      provider: 'nodemailer',
      providerOptions: {
        host: 'smtp.gmail.com',
        port: 465,
        auth: {
          user: 'gmail_username',
          pass: 'gmail_password',
        },
        // ... any custom nodemailer options
      },
      settings: {
        defaultFrom: 'username@gmail.com',
        defaultReplyTo: 'username@gmail.com',
      },
    },
  },
  // ...
});

it cant be more up to date idiot-proof

1 Like

Thanks for your answer.
I added the code in config/plugins.js, and have “strapi-provider-email-nodemailer” version ^3.6.8

I’m getting the following error, which doesn’t appear without the change, I couldn’t debug it, do you have an idea where it comes from

[2022-04-13 15:46:13.188] debug: :no_entry: Server wasn’t able to start properly.
[2022-04-13 15:46:13.190] error: provider.init is not a function

I tried the following:

module.exports = ({ env }) => ({
// …
email: {
provider: env(‘EMAIL_PROVIDER’),
providerOptions: {
host: env(‘EMAIL_SMTP_HOST’),
port: env(‘EMAIL_SMTP_PORT’),
auth: {
user: env(‘EMAIL_SMTP_USER’),
pass: env(‘EMAIL_SMTP_PASS’),
},
},
settings: {
defaultFrom: env(‘EMAIL_ADDRESS_FROM’),
defaultReplyTo: env(‘EMAIL_ADDRESS_REPLY’),
testAddress: ‘test@strapi.io’,
},
},
// …
})
I set all the variables in the .env file, the provider is nodemailer, which gives me the following error,

When running the following:
curl --location --request POST ‘localhost:1337/email/’
–header ‘Content-Type: application/json’
–data-raw ‘{“email”: “fifapik104@carsik.com”}’
{“data”:null,“error”:{“status”:401,“name”:“UnauthorizedError”,“message”:“Missing or invalid credentials”,“details”:{}}}

I get this:

{“data”:null,“error”:{“status”:401,“name”:“UnauthorizedError”,“message”:“Missing or invalid credentials”,“details”:{}}}%

I appreciate your inputs

for start are you using strapi V3 (till 3.6.8) or V4 (4.0.0. and newer) ?

you need to use corresponding provider. What i wrote you up is for V4 as im using V4.
for V3 check docu

Worked perfectly for my configuration, thanks.

  • Strapi Version: 4.13.7
  • Operating System: Ubuntu 22.04
  • Database: MySQL Latest
  • Node Version: 18.16.1