nodemailer 'From' header is missing - node.js

I got this error in my sended mail box
host gmail-smtp-in.l.google.com[74.125.195.26] said:
550-5.7.1 [23.83.209.30 11] Our system has detected that this message
is 550-5.7.1 not RFC 5322 compliant: 550-5.7.1 'From' header is missing.
550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been
550-5.7.1 blocked. Please visit 550-5.7.1
https://support.google.com/mail/?p=RfcMessageNonCompliant 550 5.7.1 and
review RFC 5322 specifications for more information. d15si13788945pgv.519 -
gsmtp (in reply to end of DATA command)
here is my code, I try to send an email from hosting with nodemailer
exports.main = ()=>{
return transporter = nodemailer.createTransport({
host: "melisandre.id.rapidplex.com",
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: 'YOI AKUAKULTUR <noreply#yoiakuakultur.com>', // generated ethereal user
pass: 'xxxxxxxxx', // generated ethereal password
},
})
}
exports.register = async (nama, username, token)=>{
let transporter = await this.main();
let info = await transporter.sendMail({
from: 'YOI AKUAKULTUR <noreply#yoiakuakultur.com>', // sender address
to: username, // list of receivers
subject: "Akun anda telah diverifikasi", // Subject line
text: "Aktivasi Akun Anda", // plain text body
html: 'test email', // html body
});
transporter.sendMail(info, (err,res)=>{
if(err){
console.log(username)
};
})
}
that'is all detail I have, did you guys know how to fix it? it was okay before

Related

nodemailer - 454 4.7.0 Too many login attempts, please try again later. j13-20020a170903024d00b0016d1b70872asm9193619plh.134 - gsmtp

I am using Nodemailer. Actually, I was using in Strapi app. I already went through many forum answers for this. Even though I have done many things I am getting this error repeatedly.
454 4.7.0 Too many login attempts, please try again later. j13 20020a170903024d00b0016d1b70872asm9193619plh.134 - gsmtp
It's happening only in my corporate email. Google(Gmail) Domain is the email provider of my corporate email. But this error is not there when I try with my Personal Gmail.
"use strict";
const nodemailer = require("nodemailer");
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
let testAccount = await nodemailer.createTestAccount();
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'support#mycorporate.com', // working fine with my personal email
pass: '<App password>',
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Fred Foo 👻" <example#gmail.com>', // sender address
to: "getting#mycopr2.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321#example.com>
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
main().catch(console.error);
Earlier, when I try this with no-reply#mycorporate.com, I was getting the same error. That's why I created a new email as support#mycorporate.com and tried this new one. Initially, it was working fine with support#mycorporate.com. But again I am getting the same error for the newly created email too.
I really can't understand why it is happening only in the corporate emails.

How to send an auto reply email with a html page as email in NodeJS

I recently started programming in NodeJS. I can't find any way how can I send an auto-reply email. When another person sends me an email, in that time an auto-reply email will be sent to his/her email, which is in HTML email format.
How can I do this?
First you need to poll or monitor your account for the incoming mail, using a generic smtp or imap client, such as https://www.npmjs.com/package/imap, or even better, a module that actually monitors new email, such as https://www.npmjs.com/package/mail-notifier
The posted example is
Start listening new mails :
const notifier = require('mail-notifier');
const imap = {
user: "yourimapuser",
password: "yourimappassword",
host: "imap.host.com",
port: 993, // imap port
tls: true,// use secure connection
tlsOptions: { rejectUnauthorized: false }
};
notifier(imap)
.on('mail', mail => console.log(mail))
.start();
Keep it running forever :
const n = notifier(imap);
n.on('end', () => n.start()) // session closed
.on('mail', mail => console.log(mail.from[0].address, mail.subject))
.start();
Next, its hard to beat nodemailer to send your response.
https://nodemailer.com/about/
Here is their example. (Half this code is comments and logs)
"use strict";
const nodemailer = require("nodemailer");
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
let testAccount = await nodemailer.createTestAccount();
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: testAccount.user, // generated ethereal user
pass: testAccount.pass, // generated ethereal password
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Fred Foo 👻" <foo#example.com>', // sender address
to: "bar#example.com, baz#example.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321#example.com>
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
main().catch(console.error);

Nodemailer fails to send email to outlook address

I am trying to use nodemailer using my Gmail address. It works when an email is sent to Gmail address but when I try to send mail to any Outlook address, it gets lost in the matrix. Help is appreciated. Thanks in advance.
let transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "Mysendergmail", // generated ethereal user
pass: "password", // generated ethereal password
}
});
transporter.sendMail({
from: '"service#onlineshop" <Mysendergmail>', // sender address
to: "myoutlookreciever", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
},(err,info)=>{
if(err){
res.status(400).json(err)
}
else res.status(200).json("sent email")
});

this is my nodemailer program Even if i give wrong mail in TO addrress also it is showing message sent how to rectifyy that

const nodemailer = require('nodemailer');
let mailTransporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: '*************',
pass: '*********',
},
});
let mailDetails = {
from: '********',
to: 'uuwdwuvw#', //guguygugiug
subject: 'Test mail',
//text: 'redeem your gift',
html: 'redeem your coupon code ',
};
mailTransporter.sendMail(mailDetails, function (err, data) {
if (err) {
console.log('Error Occurs');
} else {
console.log('Email sent successfully');
}
});
this is my nodemailer program Even if i give wrong mail in TO addrress also it is showing message sent how to rectifyy that
Nodemailer itself can't tell if an email has been delivered or not. It can tell you only if the email has been sent. There's a difference between email being sent and being delivered. Detecting bounced emails is out of scope for the Nodemailer.
In order to do that you need to implement your own bounced email mechanism, probably with your own SMTP server. It's not an easy thing to do, so you should probably use some real email provider that has this functionality instead of Gmail (Google likes to block such applications).
Have a look at the similar question I've found on GitHub and on SO.

Configure nodemailer to function with no-reply configured sender email account

I have the following code to send emails to my users from an account configured as a sender "noreply account, plus I added with the following forward filter":fail: No such person at this address. " into CPanel.
However I got an error with Nodemailer, so my question is how I could use a nonreply filter with nodemailer, any tricks I could do including probably changing the "from" field to show the recipients "noreply" account as the sender, while maybe able to send via another account ?
Note that sending works when I remove the filter from CPanel.
const mailTransport = nodemailer.createTransport({
host: 'mail.myserver.com',
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: 'noreply#myserver.com',
pass: smtpPassword
},
tls: {
// do not fail on invalid certs
rejectUnauthorized: false
}
});
const mailOptions = {
from: `App <noreply#myserver.com>`,//`${APP_NAME} <${REPLY_EMAIL}>`,//
to: email
};
// The user subscribed to the newsletter.
mailOptions.subject = subject
mailOptions.text = text;
return mailTransport.sendMail(mailOptions)
.then(() => console.log(log, email))
.catch(error => console.error('There was an error while sending the email:', error));
**Nodemailer error log:**
550-No such person at this address.
550 Sender verify failed
code: 'EENVELOPE',
response: '550-Verification failed for <noreply#myserver.com>\n550-No such person at this address.\n550 Sender verify failed',
responseCode: 550,
command: 'RCPT TO',
Use service : 'gmail' in the mailTransport object

Resources