We are gettting error Can't send mail - all recipients were rejected: 550 HELO can't be [127.0.0.1]. Please contact your ISP.
The below code was working up to last month and now its throwing error.But same mail configuration working while using c#.
`const transporter = nodemailer.createTransport({
port: 587,
host: "smtp.online.net",
auth: {
user: 'info#domain.com',
pass: 'xxxxx',
},
secure: false
});
const mailData = {
from: 'info#domain.com',
to: "test#test.com",
subject: 'subject',
html: 'message'
};
transporter.sendMail(mailData, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Sent');
});`
Related
I am trying to send emails to using nodemailer from my site but it gives me this error
Error: Invalid login: 535-5.7.8 Username and Password not accepted.
and I made sure the password and credentials is accurate. This is my code for setting up nodemailer
function message(merchantEmail, msgTxt){
var transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
secure: true,
port: 465,
auth: {
user: 'kesterdaniel401#gmail.com',
pass: process.env.PASSWORD
},
tls: {
rejectUnauthorized: false
}
});
var mailOptions = {
from: 'kesterdaniel401#gmail.com',
to: merchantEmail,
subject: 'Sending Email using Node.js',
text: msgTxt
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
module.exports = message
This is where I called the function
message(productOwner.Email, `You have received an order from ${Buyer.Name} for the product ${product. ProductName}. Please contact the customer as soon as possible. Customer Number is ${Buyer.PhoneNumber}.`)
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
secureConnection: false,
port: 587,
tls: {
ciphers: 'SSLv3'
},
requireTLS: true,
auth: {
user: 'mygmail',
pass: 'mypass'
}
});
var mailOptions = {
from: 'mygmail',
to: 'receiver gmail',
subject: 'Sending Email using Nodemailer',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, (error, info) => {
if (error)
return console.log(error);
console.log('Email sent: ' + info.response);
});
Above is my code for sending email through node js but I keep encounter a timeout error as below
{ Error: connect ETIMEDOUT 74.125.24.109:587
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
errno: 'ETIMEDOUT',
code: 'ECONNECTION',
syscall: 'connect',
address: '74.125.24.109',
port: 587,
command: 'CONN' }
I also tried another basic way as for the following link: https://www.w3schools.com/nodejs/nodejs_email.asp but it is not working as well.
I've already turned on allow the less secure app on my google account.
Beside of that, I also tried the method like the one in the following the link: https://jsfiddle.net/burawi/1u9m2mou/ and it is still unable to work, I generated all the client_id, client_secret, access_token, and refresh_token.
Does anyone have any latest guide or solution for sending email through node js?
Thanks
This is a network restriction issue.
Please try the same thing in your mobile network and it will work.
router.get('/mailTest', (req, res) => {
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: "mrmanagementbbsr#gmail.com", // generated ethereal user
pass: "Test#123" // generated ethereal password
}
});
let mailOptions = {
from: "mrmanagementbbsr#gmail.com", // sender address
to: 'nsubhadipta#gmail.com', // list of receivers
subject: "test subject", // Subject line
text: 'demo text'
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
res.json({ status: -1, message: 'Error Occured', error: error });
}
else {
res.json({ status: 1, message: "Email Sent" });
}
});
});
Ensure you turn on your Less secure app access, else your emails will not go through.
Then you might want to try this example:
{
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'mymail',
pass: 'mypass'
}
});
let mailOptions = {
from: 'mygmail',
to: 'receiver gmail',
subject: 'Sending Email using Nodemailer',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, (error, info)=>{
if (error) {
console.log(error);
} else {
console.log('Email sent ' + info.response');
}
});
res.json({success: 'whatever message you plan on writing'});
}
I am trying to use nodemailer to send an email but I keep getting this error:
Here is my code:
const nodemailer = require('nodemailer');
...
app.post('/api/SendEmail', (req, res) => {
var transporter = nodemailer.createTransport({
auth: {
user: 'x#gmail.com',
pass: 'x'
}
});
var mailOptions = {
from: 'x#gmail.com',
to: 'x#incasu.co.za',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(err, info) {
if (err) return res.status(400).send(err);
return res.status(200).send({response: 'success'});
});
})
Could someone please help me with this. I basically followed this process: https://www.w3schools.com/nodejs/nodejs_email.asp
UPDATE:
I added service: 'gmail', in the transporter as suggested by Janith Kasun:
service: 'gmail',
auth: {
user: 'x#gmail.com',
pass: 'x'
}
My error now changed to this:
I found this answer:
NodeJs Error When Submitting Email using Nodemailer
I have no idea what any of these settings do, but my emails are now being sent correctly with this code:
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: '587',
auth: {
user: "**",
pass: "**"
},
secureConnection: 'false',
tls: {
ciphers: 'SSLv3',
rejectUnauthorized: false
}
});
I am using nodemailer to send email using nodejs. Here is my code
export function createOrder(req, res) {
var transporter = nodemailer.createTransport({
service: 'gmail',
secure: false,
port: 25,
auth: {
user: 'fahadsubzwari924#gmail.com',
pass: 'Jumpshare1'
},
tls: {
rejectUnauthorized: false
}
});
var mailOptions = {
from: 'Fahad <fahadsubzwari924#gmail.com>',
to: 'shan4usmani#hotmail.com',
subject: 'Order Status ',
text: 'Your order has finished'
}
transporter.sendMail(mailOptions, function (err, res) {
if (res) {
console.log(res);
res.json({
message: res,
status: 200
})
} else {
console.log(err, 'Error');
}
})
}
When i am trying to send email then email is sending successfully but request is going on pending for a long time which is shown in network section of chrome.
How can i get rid of this request pending issue?
I failed to attach a txt file that I created earlier in the script to a mail to be sent via nodemailer. The mail is successfully sent however, it is empty. How would I fix this?
var nodemailer = require ('nodemailer');
let transporter = nodemailer.createTransport({
service: 'gmail',
secure: false,
port: 460,
auth: {
user: 'name#gmail.com',
pass: 'password'
},
tls: {
rejectUnauthorized: false
}
});
let mailOptions = {
from: "name" <'name#gmail.com',
to: 'name#gmail.com',
subject: 'group_1',
attachement: [ {
filename: 'group_1.txt',
path: /Users/derinserbetcioglu/Documents/NodeJS/'group_1.txt' } ]
};
transporter.sendMail(mailOptions, (error, info) => {
if (error){
console.log(error);
}
console.log("the message was successfully sent!")
console.log(info);
})
Try the path as path:
'/Users/derinserbetcioglu/Documents/NodeJS/group_1.txt'
instead of path: /Users/derinserbetcioglu/Documents/NodeJS/'group_1.txt'
And i think it should be attachments not attachment