dnshmail-server

SMTP server using hmailserver. Host cannot be resolved to a type


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.


Solution

  • 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:

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

    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'});
    
       })
    
    })
    

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

    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

    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");
      });
    });
    

    proof of sent mail using noreply@mydomain.com