By michaelszer
I am using nodemailer to send mails, I was available to send mails through it in c9.io but I can’t in my droplet with Ubuntu 16.04, here is my actual code to send emails:
var sendEmail = function(subjectText, bodyText) {
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
port: 443,
options: {
debug: true,
},
auth: {
user: 'altoqueMichael@gmail.com',
pass: '****'
}
});
// verify connection configuration
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take our messages');
}
});
var mailOptions = {
from: 'altoqueMichael@gmail.com',
to: 'altoqueMichael@gmail.com',
subject: subjectText,
text: bodyText
}
transporter.sendMail(mailOptions, function(error, info) {
if(error) {
console.log('Email couldnt be sent.\n', error.response);
} else {
console.log('Email sent: ' + info.response);
}
});
}
module.exports = {
sendEmail: sendEmail
}
I have already tried shutting down the firewall, what can I do to make this work? Do you know another alternative to send mails via node’js in Digital Ocean servers?
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!
Hi @michaelszer
If your account with DigitalOcean is new, then sometimes all SMTP is blocked. You need to create a ticket with Support via the control panel and ask to get SMTP unblocked.
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.