Я отправляю электронное письмо через нодмейлер, я использую транзакцию sequelize для отката вышеупомянутой задачи, если электронное письмо не отправлено, я получаю сообщение об ошибке при отклонении Promise или выдаче ошибки.Пожалуйста, помогите.
//Transaction
await db.sequelize.transaction(async t => {
const facility = await db.Facility.create(body, {transaction: t});
const user = await userCmp.addUser(email.email, t); // add user
await facilityUserCmp.addFacilityUser(facility.id, user.id, t); // add facility_user
emailCmp.verification(user, t); // notify user
if (user) {
res.status(201).send({
success: true,
errors: [],
data: facility
});
}
});
emailCmp.verification (user, t);// это функция для отправки электронного письма.
отправка кода электронной почты.
verification: (user, t) => {
try {
const smtpTransport = nodemailer.createTransport({
service: 'SendGrid',
auth: {
user: 'wrong username',
pass: 'wrong password'
}
});
const mailOptions = {
to: 'test email',
from: 'test email',
subject: 'test subject',
text: 'Testing email'
};
smtpTransport.sendMail(mailOptions)
.then((success) => {
console.log(success);
}).catch((e) => {
throw new Error(e);
});
} catch (e) {
console.log("inside catch -p---------------");
}
Исключение:
(node:10492) UnhandledPromiseRejectionWarning: Error: Invalid login: 535 Authentication failed: Bad username / password
at SMTPConnection._formatError (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:606:19)
at SMTPConnection._actionAUTHComplete (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:1335:34)
at SMTPConnection._responseActions.push.str (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:366:26)
at SMTPConnection._processResponse (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:762:20)
at SMTPConnection._onData (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:558:14)
at TLSSocket._socket.on.chunk (C:\Users\******\*****\node_modules\nodemailer\lib\smtp-connection\index.js:709:51)
at TLSSocket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at TLSSocket.Readable.push (_stream_readable.js:219:10)
at TLSWrap.onread (net.js:638:20)
(node:10492) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:10492) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Пожалуйста, помогите мне.