I'm creating the authentication form and email activation, everything was fine, until I started to create the send mail activation function. I'm a newbie in backend development and I've no idea how to solve this problem, but in my gmail account I have text like that:
"To help keep your account secure, from May 30, 2022, Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password. Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date. For more information, continue to read."
There is my error:
Error:
Error: 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 2-20020ac25f02000000b0049480c8e7bcsm796078lfq.176 - gsmtp
at SMTPConnection._formatError (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:787:19)
at SMTPConnection._actionAUTHComplete (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:1539:34)
at SMTPConnection.<anonymous> (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:543:26)
at SMTPConnection._processResponse (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:950:20)
at SMTPConnection._onData (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:752:14)
at TLSSocket.SMTPConnection._onSocketData (C:\Users\User\Desktop\app-redesigned-6\server\node_modules\nodemailer\lib\smtp-connection\index.js:191:44)
at TLSSocket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at TLSSocket.Readable.push (node:internal/streams/readable:228:10) {
code: 'EAUTH',
response: '535-5.7.8 Username and Password not accepted. Learn more at\n' +
'535 5.7.8 https://support.google.com/mail/?p=BadCredentials 2-20020ac25f02000000b0049480c8e7bcsm796078lfq.176 - gsmtp',
responseCode: 535,
command: 'AUTH PLAIN'
}
And there's my script:
mail-service.js
const nodemailer = require("nodemailer");
class MailService {
constructor() {
this.transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false,
auth: {
user: "gmail@gmail.com",
pass: "password",
},
});
}
async sendActivationMail(to, link) {
await this.transporter.sendMail({
from: "gmail@gmail.com",
to: "ruslanmakhmatov@gmail.com",
subject: "Account Activation For Intelligence.io",
text: "",
html: `
<div>
<h1>In Order To Activate Account - Click The Link</h1>
<a href="${link}">${link}</a>
</div>`,
});
}
}
module.exports = new MailService();
And the last question is, how can I add email verification using other technologies and not nodemailer?