Hello everyone,
I have a express.js app installed in a centOS server. I have a code that in my local environment works fine, but in the centOS doesn’t work.
Here is the code:
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
options: {
debug: true
},
auth: {
user: "user@gmail.com",
pass: " ********* "
}
});
…
transporter.sendMail(mailOptions, (err, info) => {
if(err){
console.log(err);
return res.render('index.html', {HOME: req.home, mensagem: 'Erro no envio de mensagem', erro: 1});
}
return res.render('index.html', {HOME: req.home, mensagem: 'Email enviado com sucesso', erro: 0});
})
It’s a nodemailer module from npm. I tried to check with there is any mistake on my SMTP port, but i didn’t find anything.
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Without more information it is difficult to know what the underlying cause of this issue is. I would recommend reviewing your logs. One thing I have seen before is that gmail will not always allow a connection via SMTP from a new machine without requiring you to log in with a web browser.
For a service that needs to send email via SMTP I would recommend using a 3rd party service like SendGrid (they allow up to 12k monthly email sends for free) to ensure delivery and ease the setup process.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.