nodemailer show mail sent successfully,but not received in hotmail or gmail, see debug information:
[2019-12-25 20:07:21] DEBUG Creating transport: nodemailer (6.4.2; +https://nodemailer.com/; SMTP/6.4.2[client:6.4.2])
[2019-12-25 20:07:21] DEBUG Sending mail using SMTP/6.4.2[client:6.4.2]
[2019-12-25 20:07:21] DEBUG [8iKNVLchDJw] Resolved smtp.ethereal.email as 178.32.207.71 [cache miss]
[2019-12-25 20:07:21] INFO [8iKNVLchDJw] Connection established to 178.32.207.71:587
[2019-12-25 20:07:22] INFO [8iKNVLchDJw] Connection upgraded with STARTTLS
[2019-12-25 20:07:22] DEBUG [8iKNVLchDJw] SMTP handshake finished
[2019-12-25 20:07:22] INFO [8iKNVLchDJw] User "gtgkm7szk3abifr3@ethereal.email" authenticated
[2019-12-25 20:07:22] INFO Sending message e36beea0-2ee6-fa3a-6d63-6d3cf20429d8@ethereal.email to tomert@hotmail.com
[2019-12-25 20:07:22] INFO [8iKNVLchDJw] <318 bytes encoded mime message (source size 315 bytes)>
[2019-12-25 20:07:22] DEBUG [8iKNVLchDJw] Closing connection to the server using "end"
Email has been sent
https://ethereal.email/message/XgPBeQXHOwzashBtXgPBeiwGigyp0rYgAAAAAR.aTWqijqF4tGifeFS4.ik
POST /sendmail 200 2241.633 ms - 359
this is the code:
const sendMail = (callback) => {
console.log('send mail')
let testAccount ;
nodemailer.createTestAccount((err, account) => {
if (err) {
console.error('Failed to create a testing account');
console.error(err);
return process.exit(1);}
else{
console.log('testAccount' + account);
console.log('Credentials obtained, sending message...');
const transporter = nodemailer.createTransport({
name: '127.0.0.1',
host: account.smtp.host,
port: account.smtp.port,
secure: account.smtp.secure,
auth: {
user: account.user,
pass: account.pass
},
// sender address
headers: {
'X-Laziness-level': 1000 // just an example header, no need to use this
},
logger: true,
debug: false // include SMTP traffic in the logs
});
const mailOptions = {
from:account.user,
to: "mymail@hotmail.com",
subject: "Contact Request",
html: "<h1>And here is the place for HTML</h1>"
};
transporter.sendMail(mailOptions, callback);
}
});
}
router.post("/",(req,res)=>{
console.log("request came");
//let user = req.body;
//console.log(user)
sendMail( (err, info)=>{
if (err) {
debugger;
console.log(err);
res.status(400);
res.send({ error: "Failed to send email" });
}
else{
console.log("Email has been sent");
console.log(nodemailer.getTestMessageUrl(info));
res.send(info);
}
});
});
module.exports = router;
nodemailer show mail sent successfully,but not received in hotmail or gmail, see debug information: [2019-12-25 20:07:21] DEBUG Creating transport: nodemailer (6.4.2; +https://nodemailer.com/; SMTP/6.4.2[client:6.4.2]) [2019-12-25 20:07:21] DEBUG Sending mail using SMTP/6.4.2[client:6.4.2] [2019-12-25 20:07:21] DEBUG [8iKNVLchDJw] Resolved smtp.ethereal.email as 178.32.207.71 [cache miss] [2019-12-25 20:07:21] INFO [8iKNVLchDJw] Connection established to 178.32.207.71:587 [2019-12-25 20:07:22] INFO [8iKNVLchDJw] Connection upgraded with STARTTLS [2019-12-25 20:07:22] DEBUG [8iKNVLchDJw] SMTP handshake finished [2019-12-25 20:07:22] INFO [8iKNVLchDJw] User "gtgkm7szk3abifr3@ethereal.email" authenticated [2019-12-25 20:07:22] INFO Sending message e36beea0-2ee6-fa3a-6d63-6d3cf20429d8@ethereal.email to tomert@hotmail.com [2019-12-25 20:07:22] INFO [8iKNVLchDJw] <318 bytes encoded mime message (source size 315 bytes)> [2019-12-25 20:07:22] DEBUG [8iKNVLchDJw] Closing connection to the server using "end" Email has been sent https://ethereal.email/message/XgPBeQXHOwzashBtXgPBeiwGigyp0rYgAAAAAR.aTWqijqF4tGifeFS4.ik POST /sendmail 200 2241.633 ms - 359
this is the code: const sendMail = (callback) => {
console.log('send mail') let testAccount ; nodemailer.createTestAccount((err, account) => { if (err) { console.error('Failed to create a testing account'); console.error(err); return process.exit(1);}
}
router.post("/",(req,res)=>{ console.log("request came"); //let user = req.body; //console.log(user) sendMail( (err, info)=>{ if (err) { debugger; console.log(err); res.status(400); res.send({ error: "Failed to send email" }); } else{ console.log("Email has been sent"); console.log(nodemailer.getTestMessageUrl(info)); res.send(info); } }); }); module.exports = router;