Monday 29 April 2019

changed hosting providers, nodemailer not working anymore

Hey guys,​so previously I had a contact us form that just sends me an email using nodemailer. I switch hosts and noticed it didn't work so I realized I still had my old host info etc.. I created a new email account under cPanel and the new hosting and adjusted my function but it doesn't seem to work. I've spent a couple of days and don't know what would cause it. I keep getting this e-mail, I verified sending an email to the account using my phone and it works, so I even verified the email settings and it matches my code config (port 465, hostname). I've tried diff combinations (port:587, secure:false) and nothing seems to work​This is the sample code:app.post('/contactsubmit',function (req, res) {let mailOpts, smtpTrans;smtpTrans = nodemailer.createTransport({host: 'server218.web-hosting.com',port: 465,secure:true,auth: {user: 'support@bubble-tech.ca',pass: 'dummypassword123'},tls: {// do not fail on invalid certsrejectUnauthorized: false}});mailOpts = {from: 'test@noreply.com',to: 'support@bubble-tech.ca',subject: 'test subject',text: 'please work'};smtpTrans.verify(function(error, success) {if (error) {console.log("verify error"+error);} else {console.log("Server is ready to take our messages");}});smtpTrans.sendMail(mailOpts, function (error, response) {if (error) {console.log(error);}else {res.render('contact-success');}});});

Submitted April 29, 2019 at 07:07PM by akash227

No comments:

Post a Comment