import nodemailer from "nodemailer";
// transporter object
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true then port will change
requireTLS:true,
auth: {
user: "mygmail@gmail.com",
pass:"myapppassword" //google app password
}
})
// mail object
const mailOptions = {
name:"hello",
from: "my@gmail.com",
to: "myfriend@gmail.com", //allowed comma separated mutiple emails
subject: "Node js mail text",
text: "hello buddy aapke father aaye hain!"
}
// send mail
transporter.sendMail(mailOptions, (err, res) => {
if (err) {
console.log(err)
} else {
console.log(res.response)
}
})
In the above code snippet i tried send text email to another account and it is sent successfully but i am not receiving the email but when i try to send the email to the same email it is getting inside the inbox , why it is happening ? Thank you