By aditicshetty
I am relatively new to Node.js and Digitalocean. I have a website hosted on digitalocean - www.domainname.com. The domain name was registered with GSuite. I want to send a verification email from support@domainname.com to a gmail address, say example@gmail.com.
I tried using the nodemailer module for this. When I try to send an email from my my own gmail address I can send the verification link to any email account. But when I try to send an email from ‘support@domain.com’, I get ‘Invalid login’ error in the log files.
I use the following code to send the email:
var mail=example@gmail.com;
var code="*******";
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'support@domainname.com',
pass: 'password'
}});
var mailOptions = {
to: mail,
subject: 'Verify your account',
text: 'Veify your account',
html: " <a href='http://www.domainname.com/verification?code="+code+"'> http://www.domainname.com/verification?code="+code+" </a> "
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
This is the error message in the log file:
Error: Invalid login.
<https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv
Please log in via your web browser and then try again.
Learn more at https://support.google.com/mail/answer/78754
Any help would be appreciated…
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 - I see this post is old, but I am experiencing the same issue . Any suggestion? Thanks!
Hey, I have also experienced the same issue earlier today and enabling UnlockCaptcha has resolved this issue, (https://accounts.google.com/b/0/DisplayUnlockCaptcha) try enabling this option to your Gmail account which you’re using in nodemailer.
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.