Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email gets sent but not received #137

Open
tomertro opened this issue Dec 25, 2019 · 0 comments
Open

Email gets sent but not received #137

tomertro opened this issue Dec 25, 2019 · 0 comments

Comments

@tomertro
Copy link

tomertro commented Dec 25, 2019

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 "[email protected]" authenticated
[2019-12-25 20:07:22] INFO Sending message [email protected] to [email protected]
[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: "[email protected]",
    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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant