Node mailer
most of them know Node mailer but with latest security update of google some of them not able to use Node mailer , Don't worry I will help you to resolve your issue ... if you are a beginer you can also follow this documentation....Let's start
step 1
install node mailer in your server
npm install nodemailer
step 2
Add this code
**const nodemailer = require('nodemailer')
const sendmail= async (req, res) => {
const { email } = req.body;
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "example@gmail.com",
pass: "***",
},
});
try {
// send mail using optional parameters
var mailOptions = {
from: "example@gmail.com",
// here you an replace email with custom email name //
to: email,
subject: "Type your e-mail subject here",
html: `
<img style="width:100px;height:40px;object-fit:contain" src="https://example/Image/example.jpeg" alt="Yourimge">
<h2Email recciewvedlick Here to test </h2>
`,
};
// get the response
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log("Email sent: " + info.response);
return res.status(200).json({ success: true, message: info.response });
}
});
} catch (err) {
console.log(err);
}
};
**
inside auth we need to give password i mentioned in top the google is updated the security information so we need to follow the latest updates
so follow me to get your password
You need to secure your google account with two step verification
next go to this link
- Then you add any custom name and then you will get 16 digit password copy that password
and add that password inside the auth in given code above
remember one thing email also replace with your email which created app password
(26
-10-2023)
official documentation : https://nodemailer.com/
If there is still a problem contact me :
https://https://www.linkedin.com/in/manu1305/
whatsapp :+91 8943293217
Top comments (0)