nodemailer online.net 550-HELO can't be [127.0.0.1]. Please contact your ISP - smtp

I have a problem on sending mails online.net with nodemailer.
While it works fine with chilkat's mailman module (node.js) on the same environment
nodemailer version
let transporter = nodemailer.createTransport({
host: "smtpauth.online.net",
port: 587,
secure: false,
auth: {
user: "xxx#domain.fr",
pass: "xxx",
},
tls: {
rejectUnauthorized: false,
},
});
transporter
.sendMail({
from: "xxx#domain.fr",
to: "true#eadress.fr",
subject: "Test online",
text: "Test online"
})
.then((info) => {
console.log("Preview URL: " + nodemailer.getTestMessageUrl(info));
})
.catch((error) => {
console.log(error);
});
chilkat-version
var mailman = new chilkat.MailMan();
mailman.SmtpHost = "smtpauth.online.net";
mailman.SmtpUsername = "xxx#domain.fr";
mailman.SmtpPassword = "xxx";
mailman.SmtpSsl = false;
mailman.StartTLS = true;
mailman.SmtpPort = 587;
var email = new chilkat.Email();
email.Subject = "Test online";
email.Body = "Test online";
email.From = "xxx#domain.fr";
var success = email.AddTo("Bob","true#eadress.fr");
success = mailman.SendEmail(email);
if (success !== true) {
console.log(mailman.LastErrorText);
return;
}
success = mailman.CloseSmtpConnection();
if (success !== true) {
console.log("Connection to SMTP server not closed cleanly.");
}
console.log("Mail Sent!");
Following the scaleway doc (https://www.scaleway.com/en/docs/webhosting/classic/how-to/check-emails/), I tried all ports (25, 465, 587, 2525 ). I changed the host from smtpauth.online.net to smtp.online.net, nothing helped.
If anyone has solved this problem that would be a great help. Thanks

I found the solution.
it works by adding "name" option in createTransport
name – optional hostname of the client, used for identifying to the server, defaults to hostname of the machine
let transporter = nodemailer.createTransport({
name: 'www.domain.com',
host: "smtpauth.online.net",
port: 587,
secure: false,
auth: {
user: "xxx#domain.fr",
pass: "xxx",
},
tls: {
rejectUnauthorized: false,
},
});

Related

Connection closed unexpectedly: Nodemailer

const express = require('express');
const app = express();
const nodemailer = require('nodemailer');
//Middleware
app.use(express.static('frontend'));
app.use(express.json());
app.get('/',(req,res)=>{
res.sendFile(__dirname + '/frontend/index.html');
});
app.post('/', (req,res)=>{
console.log(req.body);
const transporter1 = nodemailer.createTransport({
service:"gmail",
host: "smtp.gmail.com", // hostname
secure: false, // use SSL
port: 587, // port for secure SMTP
auth: {
user: "my email id",
pass: "mypassword"
},
tls: {
ciphers: "SSLv3",
rejectUnauthorized: false,
},
});
const mailOptions = {
from:req.body.email,
to: 'prahlad.hsrao#gmail.com',
cc: '24septanjali#gmail.com',
subject: 'Form Information',
text:"firstName: "+ req.body.fname+"\n" + "lastName"+req.body.lname+"email" + req.body.email+"phone"+req.body.phone+"message"+req.body.message,
}
transporter1.sendMail(mailOptions,(error,info)=>{
if(error){
console.log(error);
res.send('error');
transporter1.close();
}
else{
console.log('Email sent' + info.response);
res.send('success');
res.redirect('/');
transporter1.close();
}
})
})
app.listen(3000,()=>console.log('Server started...'));
firstly it was working perfectly, I send the email successfully 5-6 time, then while trying to send the mail, it is giving following error.
Error: Connection closed unexpectedly
at SMTPConnection._onClose (D:\official\SendEmailProject\nodeContactForm\node_modules\nodemailer\lib\smtp-connection\index.js:827:34)
at TLSSocket.SMTPConnection._onSocketClose (D:\official\SendEmailProject\nodeContactForm\node_modules\nodemailer\lib\smtp-connection\index.js:193:42)
at Object.onceWrapper (node:events:628:26)
at TLSSocket.emit (node:events:525:35)
at node:net:757:14
at TCP.done (node:_tls_wrap:584:7) {
code: 'ECONNECTION',
command: 'CONN'
I also got this error. After searching I guess it's a problem with the email server. I got about 5% of all my auto emails to fail. Maybe we can try to change one.

How to store log using Winston logger in Mysql DB?

I have written according to winston-mysql document. I have described a table in mysql db for storing logs but it's not working.The below is my logger.js -
const winston = require('winston');
const winston_mysql = require('winston-mysql')
var options_default = {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
table : 'log',
fields : { level: 'info', meta: 'metadata', message: 'source', timestamp: 'addDate'}
};
var logger = new (winston.createLogger)({
transports: [
new winston_mysql(options_default)
]
});
module.exports = logger;
And this is my controller file where I am using winston.After customer is created it should create a log file into the db. I am not getting any error as such but its not storing into db.What mistake I am doing?
const createCustomer = async(req,res,next) => {
try{
var id = Math.floor(Math.random()*9000000) + 10000000;
var db = req.con;
const data = {
"id": id,
"first_name": req.body.first_name,
"last_name": req.body.last_name ,
"username": req.body.username,
"email": req.body.email,
"password": req.body.password,
"mobile": req.body.mobile,
"address": req.body.address,
"created_date": CurrentTime,
};
console.log(data)
const salt = await bcrypt.genSalt(20);
data.password = await bcrypt.hash(data.password, salt);
var pass = data.password;
console.log(pass)
if (!req.file.filename)
return res.status(400).send('No files were uploaded.');
let filename = fs.readdirSync('./src/template-store/temporaryImage/')
console.log(filename)
var file = req.files
let result = db.query(`INSERT INTO customer set ?`,[data],function(err,rows){
if(err){
res.json({
success:0,
message:"An error occurred",
err
})
}
else{
logger.log({level:'info',message : 'customer'}) // here I am using logger
res.json({
status:1,
message:"Inserted",
data: data
})
// mailer(req.body.username,req.body.email,req.body.password)
}
})
}
catch(error){
res.json({
status:0,
message:"An error occured",
error:error
})
}
}

Nodemailer Email sending not working

I'm trying to send an email from my application. I tried the below code. Can someone please help me where I'm wrong?
When I'm submitting my form, I'm not getting any error. But, I'm not able to get the email on the recipient side.
Thank you
'use strict';
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
// host: 'smtp.gmail.com',
service: "Gmail",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'xyz#gmail.com',
pass: '**********'
}
});
/**
* Module dependencies.
*/
var path = require('path'),
mongoose = require('mongoose'),
Enquire = mongoose.model('Enquire'),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller')),
_ = require('lodash');
exports.sendMail = function(req, res) {
var data = req.body;
rand=Math.floor((Math.random() * 100) + 54);
host=req.get('host');
console.log("send MailData :: " + data)
var link="http://"+req.get('host')+"/verify?id="+rand;
var mailOptions={
from: data.contactEmail,
to : 'abc#gmail.com',
subject : "Please confirm your Email account",
html : "Hello,<br> This is your test email for the Inquiry Form."
}
console.log(mailOptions);
transporter.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
res.end("error");
}else{
console.log("Message sent: " + response.message);
res.end("sent");
}
});
res.json(data);
};

Setting up proxy in chrome extension

I would like to allow to use proxies on my chrome extension but no matter what user enters, ERR_NO_SUPPORTED_PROXIES appears.
Here is my code for proxy connection:
var prxobj = JSON.parse(localStorage['proxy']);
ip = prxobj['proxyip'];
port = parseInt(prxobj['proxyport']);
var obj = {
mode: 'fixed_servers',
rules: {
singleProxy: {
scheme: 'https',
host: ip,
port: port
},
bypassList: ['']
}
};
chrome['proxy']['settings']['set']({
value: obj,
scope: 'regular'
}, function() {})
Code for proxy auth:
chrome['webRequest']['onAuthRequired']['addListener'](function(first, second) {
var objx= JSON.parse(localStorage['proxy']);
first({
authCredentials: {
username: objx['proxyusername'],
password: objx['proxypassword']
}
})
}, {urls: ['<all_urls>'] }, ['asyncBlocking']);

Nodemailer Sendgrid on Compute Engine

i trying to send emails from my compute engine instance but nothing happen(no error message). When i send mails from my local pc i get the emails.
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var options = {};
var transporter = nodemailer.createTransport(smtpTransport({
service: 'SendGrid',
auth: {
user: 'username',
pass: 'password'
}
}));
module.exports = {
sendmailto : sendmailto
}
function sendmailto(emailfrom,emailto, message){
var mailOptions = {
from: emailfrom, // sender address
to: emailto, // list of receivers
subject: 'Monitoring', // Subject line
text: message, // plaintext body
html: '<b>Monitoring</b>' +
'<p> '+message+'<p>' // html body
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}else{
console.log('Message send: ', + info.response);
}
});
};
I found the reason be myself:) Service "Sendgrid use as standard port the 25 but is does not work with compute engine so i need to add the port 2525.
var transporter = nodemailer.createTransport(smtpTransport({
service: 'SendGrid',
port: '2525',
auth: {
user: 'username',
pass: 'password'
}
}));