I am new to Nodemailer and I am getting this error when a user contacts me in a contact form. I am using express for this. Here is the error:
Error: Message failed: 553 Relaying disallowed as email@gmail.com
at SMTPConnection._formatError (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
at SMTPConnection._actionSMTPStream (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:1661:34)
at SMTPConnection.<anonymous> (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:1146:22)
at SMTPConnection._processResponse (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:942:20)
at SMTPConnection._onData (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)
at TLSSocket.SMTPConnection._onSocketData (/Users/raghavherugu/Documents/localmainstreetbackend/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
at TLSSocket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at TLSSocket.Readable.push (_stream_readable.js:209:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23) {
code: 'EMESSAGE',
response: '553 Relaying disallowed as email@gmail.com',
responseCode: 553,
command: 'DATA'
}
email@gmail.com is the email of the user trying to contact me, such as JohnDoe@gmail.com, etc. I am also using Zoho.
Here is my code:
var transport = {
host: "smtp.zoho.eu",
port: 465,
secure: true,
auth: {
user: creds.USER, // I have a separate file with my email and password
pass: creds.PASS, // I have a separate file with my email and password
},
};
var transporter = nodemailer.createTransport(transport);
router.post("/send", (req, res, next) => {
const { error } = contactValidation(req.body); // Just a separate function to validate If the user has submitted all entries using Joi
if (error) return res.send(error.details[0].message);
var name = req.body.name;
var email = req.body.emailc;
var message = req.body.message;
var content = `name: ${name} \n email: ${email} \n message: ${message} `;
var mail = {
from: email,
to: "myEmail@email.com",
subject: "New Message from Contact Form",
text: content,
};
transporter.sendMail(mail, (err, data) => {
if (err)
console.log(err);
res.json({
status: "fail",
});
} else {
res.json({
status: "success",
});
transporter.sendMail(
{
from: "myEmail@email.com",
to: email,
subject: "Submission was successful",
text:
"Thank you for contacting us! We appreciate your feedback and will strive to get better!",
},
function (error, info) {
if (error) {
console.error(error);
} else {
console.log("Message sent: " + info.response);
}
}
);
}
});
});
I have no idea what is the cause for this error.
I have tried:
- Updating my Zoho DNS records using Zeit(now Vercel, I am using this for hosting my website)
- Adding DKIM records to my email
I also do not know what this error means. If anyone can help, I would appreciate it! Thanks in advance.