I'm trying to send emails using nodemailer using
let transporter = nodemailer.createTransport({
host: 'mail.hover.com',
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: 'myemail@mydomain.com',
pass: 'password',
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: {
name: 'My name',
address: 'myemail@mydomain.com',
}, // sender address
replyTo: 'myemail@mydomain.com',
to: 'recipient@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>', // html body
});
This sends the email as intended, but Gmail gives a warning that "Gmail couldn't verify that mydomain.com actually sent this message (and not a spammer)". I was wondering if there was a way to send the email in such a way that Gmail would know that myemail@mydomain.com actually sent the email.
Thanks!
Found a solution. I essentially allowed emails from my to be sent from my custom email. I followed the guide here: https://support.google.com/mail/answer/22370?hl=en.
Open Gmail.
In the top right, click Settings Settings and then See all settings.
Click the Accounts and import or Accounts tab.
In the "Send mail as" section, click Add another email address.
Enter your name and the address you want to send from (my custom email).
Click Next Step and then Send verification.
For the SMTP server, I put mail.hover.com (since that's what I'm using)
Sign in to my custom domain and click the verification link
Send Email using NodeMailer
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'mygmailuser@gmail.com',
pass: 'password',
},
});
let info = await transporter.sendMail({
from: {
name: 'My name',
address: 'myemail@mydomain.com',
},
to: 'recipient@gmail.com',
subject: 'Hello ✔',
text: 'Hello world?',
html: '<b>Hello world?</b>',
});