0

I am trying to create a local SMTP server. I configured everything according to this: Link to set-up hmailserver

After that, I ran my diagnostics thing and it said host(in my case, noreply@bufferoverflow.com) cannot be resolved. I googled and read the documentation and question section of hmailserver Docs and found that I am missing a DNS configuration on my machine.

I followed this article to set-up the DNS ip to name: How to add ip domain mapping in windows

127.0.0.1 bufferoverflow.com

on my

C:\Windows\System32\drivers\etc>notepad hosts.ics

It still said host cannot be resolved to a type. I tried to see if the port was actually open and listening. So I did this command in CMD:

netstat -a

It's listening. I doubled checked everything but coudn't found where I was going wrong. I created a simple nodejs server and hosted it on port 80 at localhost and typed "bufferoverflow.com" in my browser it opened 127.0.0.1 aka localhost which is because it has an ip domain mapping I have given.

Now I am lost as why the hostname can't be resolved. My DNS is cool. Everthing is configured as docs says and the port is also open and listening. Please help me.

Shobhit Tewari
  • 535
  • 5
  • 20
  • What is "my diagnostics thing"? – Dusan Bajic Nov 06 '20 at 10:15
  • In the set-up guide, the last thing it says is to check if the server is actually running and everything is alright. Like a dummy check. That's the diagnostics window. Look at the pictures attached in the article. – Shobhit Tewari Nov 06 '20 at 10:18
  • 1
    Hey are you bounded to using this? I can take you through an easy step error free having a ready made SMTP sometime you have to ask for activation + it's free no charges 300mails a day that you can send – Ntshembo Hlongwane Nov 06 '20 at 15:04
  • No sir I wanted to send mail from my server. I got to know about nodemailer. I created a less secure google account and achieved that. But I needed the mail from my custom domain like, noreply@mydomain.com Got to know about sendgrid and then understood that I needed my own SMTP server. After some time I understood that if I have my own SMTP why do I even need send grid. Then I searched to create my own SMTP server. I came across this thing and was stuck here. This is the whole problem. PS: I haven't purchased the domain. – Shobhit Tewari Nov 06 '20 at 18:17

1 Answers1

1

So based on what you said you created your own SMTP server which is nice and all to learn, but I would recommend using SendinBlue 3rd party service FREE and gives you 300 mails/day

Getting Started with sendinblue:

  • Link: https://www.sendinblue.com/

  • Go make and an account free of charge till you decide to pay you'll read there

  • Once your account is all set, and activated often SMTP service for ones account is not automatically activate so you'd have to email them and they literally respond within 24hr I LOVE THE SERVICE(I am not promoting nor sponsored to hype them or anything just saying the truth of what I have experienced).

So now at this point your account and SMTP service is activated, now question is how do you use sendinBlue?

  • In your dashboard on your Top right you will see your username

  • Click on that and a dropdown menu should appear

  • Then you want to go to SMTP & API

  • Once you then you will see a menu with API Keys on the left and SMTP on the right

  • You want to click on the SMTP.

  • Once you the you will see Login that would be the email you registered with and you will see Master password now that is what you use to authenticate yourself.

Implementation: Now you have everything sorted you know where you keys are and login

In .env file

sendinBlue__login=<Your email that your saw in that smtp tab>
sendinBlue__key= <Key you saw in that smtp tab>

In your file where you want to send email

const nodemailer = require('nodemailer');
router.post('/api/email', (request, response)=>{

   const transporter = nodemailer.createTransport({

       service:'SendinBlue',
       auth:{
           user:process.env.sendinBlue__login,
           pass:process.env.sendinBlue__key
       }

   })


   const mailOptions = {
       from:process.env.sendinBlue__login
       to:'example@gmail.com',
       subject:'Order confirmation',
       html:`

           <h1>Confirmation of your received  order</h1>

       `
 
   }


   transporter.sendMail(mailOptions, (error, info)=>{

       if (error){
           console.log(error);
           return response.status(500).json({msg:"Email failed to send probably network problems or SMTP not activated"});

       }
       return reponse.status(200).json({msg:'Email sent'});

   })

})
  • Now this is how easy sendinBlue works just simple signup and account activation also SMTP activation if not activated from get go by email customer support

If that guide above did not make sense to you: Shameless plug

  • You can go checkout my video that I did and I was using sendinBlue with nodemailer for emailing it's a bit at the end

  • Link: https://youtu.be/5vWXbGIdDQw

Now If you want to send an email using noreply@domain.com with sendinBlue you do not even have to have the email activated but still can send

  • How you go about this is the way you craft your mailOptions
router.get("/api/test", (request, response) => {
  const transpoter = nodemailer.createTransport({
    service: "SendinBlue",
    auth: {
      user: process.env.sendinBlue__email,
      pass: process.env.sendinBlue__key,
    },
  });

  const mailOptions = {
    from: "noreply@Test.com",
    to: "juniorWebProjects@gmail.com",
    subject: "Confirmation Order",
    html: `
       
       <h1>Order Received</h1>
    
    `,
  };

  transpoter.sendMail(mailOptions, (err, info) => {
    if (err) {
      return console.log(err);
    }
    return console.log("Message sent");
  });
});
  • See on my mailOptions I explicitly wrote myself the email that I want and when sendinBlue sends that email the receiver will see that is coming from noreply@Test.com

proof of sent mail using noreply@mydomain.com