adonisjs / mail

AdonisJS Email Provider
MIT License
104 stars 34 forks source link

AdonisJS : Can't send email via @adonisjs/mail #80

Closed atjab closed 2 years ago

atjab commented 2 years ago

I use adonis js version 4.1.0 and @adonisjs/mail version ^3.0.10. I'm not sure why. But I'm sure my email and password are correct which previously email can be used normally. Please help me. Thank for your solution. I got this error when I send email ExceptionHandler Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 136-20020a62188e000000b0050dc7628158sm4991712pfy.50 - gsmtp

my .env file

MAIL_USERNAME=test@gmail.com
MAIL_PASSWORD=testpw
SMTP_HOST=smtp.gmail.com

and using

  const data = `<div>Testing</div>`;
  await Mail.raw(data, (message) => {
      message.to(getEmail.email);
      message
      .from(`${Env.get("MAIL_USERNAME")}`)
      .subject("Test Email Sending");
  });

In config/mail.js

connection: Env.get('MAIL_CONNECTION', 'smtp'),
smtp: {
    driver: 'smtp',
    pool: true,
    port: Env.get('SMTP_PORT', 465),
    host: Env.get('SMTP_HOST'),
    secure: true,
    auth: {
        user: Env.get('MAIL_USERNAME'),
        pass: Env.get('MAIL_PASSWORD')
    },
    maxConnections: 5,
    maxMessages: 100,
    rateLimit: 10
 },

In my package.json

{
     "name": "adonis-api-app",
     "version": "4.1.0",
     "adonis-version": "4.1.0",
     "description": "Adonisjs boilerplate for API server with pre-configured JWT",
     "main": " --inspect index.js",
     "scripts": {
         "start": "nodemon --inspect=0.0.0.0:3333 server.js",
          "test": "node ace test",
          "debug": "nodemon --inspect=0.0.0.0:3333 server.js",
          "migrate": "node database/script_migration/migrate_prevaa.js"
      },
     "keywords": [
         "adonisjs",
         "adonis-app"
      ],
     "author": "",
     "license": "UNLICENSED",
     "private": true,
     "dependencies": {
         "@adonisjs/ace": "^5.0.8",
         "@adonisjs/ally": "2.2.0",
         "@adonisjs/auth": "^3.0.7",
         "@adonisjs/bodyparser": "^2.0.9",
         "@adonisjs/cli": "^4.0.12",
         "@adonisjs/cors": "^1.0.7",
        "@adonisjs/drive": "^1.0.4",
        "@adonisjs/fold": "^4.0.9",
        "@adonisjs/framework": "^5.0.9",
        "@adonisjs/ignitor": "^2.0.8",
        "@adonisjs/lucid": "^6.2.0",
       "@adonisjs/lucid-slugify": "^1.0.3",
       "@adonisjs/mail": "^3.0.10",
       "@adonisjs/session": "^1.0.29",
       "@adonisjs/shield": "^1.0.8",
       "@adonisjs/validator": "^5.0.6",
       "adonis-lucid-polymorphic": "^1.0.1",
       "adonis-scheduler": "^3.0.2",
       "aws-sdk": "^2.788.0",
       "axios": "^0.21.0",
       "directory-tree": "^2.2.5",
       "faker": "^5.1.0",
       "html2json": "^1.0.2",
       "json-find": "^2.0.7",
       "lodash": "^4.17.21",
       "lucid-mongo": "^3.1.6",
       "mysql": "^2.18.1",
       "numeral": "^2.0.6",
       "sqlite3": "^5.0.0"
  },
 "devDependencies": {},
  "autoload": {
       "App": "./app"
  }
}
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.