I have a weird problem with my email setup. When I send emails from my Netlify function using my custom domain, Gmail shows an authentication warning but only in certain cases.
My current setup:
- Using nodemailer for sending emails
- Custom domain SMTP server
- All DNS records are set up (SPF, DKIM, DMARC)
The strange part:
When I send emails directly to Gmail addresses, everything works fine. But when emails go to my custom domain first and then get forwarded to Gmail through POP3, Gmail displays the authentication warning.
Here’s my email sending code:
const deliverMessage = async (config) => {
try {
const mailTransporter = nodemailer.createTransporter({
host: 'mail.hostingservice.net',
port: 465,
secure: true,
auth: {
user: process.env.MAIL_USER,
pass: process.env.MAIL_PASS
}
});
const messageConfig = {
from: `MyCompany Support <${process.env.MAIL_USER}>`,
to: config.recipient,
subject: config.title,
html: config.content,
};
if (config.attachment) {
messageConfig.attachments = [{
filename: config.attachment.name,
content: config.attachment.data
}];
}
await mailTransporter.sendMail(messageConfig);
} catch (err) {
console.log("Mail delivery failed:", err);
throw err;
}
}
exports.handler = deliverMessage;
What I’ve tried:
- Double checked all DNS authentication records
- Verified SMTP settings multiple times
- Tested different email clients
Is this a known issue with POP3 forwarding? Does anyone know how to fix this authentication warning when emails are forwarded through POP3 to Gmail?