I'm using the Nodemailer Node.js module to interface with sendmail. However, my emails go directly to the spam folder when reached by a Gmail account. Why are my emails being shit-canned? It must be something to do with the headers of the email, but I have no idea what it could be.
I'm not really familiar with emails and what spam filters look for, so could someone please provide me with some details on what to watch out for?
Thanks for reading. :)
I've faced with the same issue and was able to fix it by updating 'from' field to this format:
from: 'Sender Name <[email protected]>'
complete code:
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
requireTLS: true,
auth: {
user: '[email protected]',
pass: 'pass'
},
from: '[email protected]'
});
const mailOptions = {
from: 'Sender Name <[email protected]>'
to: '[email protected]',
subject: 'Subject',
text: 'Text'
};
return transporter.sendMail(mailOptions, (error, info) => {
...
});
Here's a few reasons: http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html
There are also blacklists of ip addresses. Anything coming from these would just be ignored or regarded as spam. If your email is sent from a server which doesn't seem to be linked to the from address you'll have potential issues as well.
Detecting spam and trying not to be seen as spam are both non trivial things. That's why a lot of mailing lists are done through a specialist provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With