Reputation: 21
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: '[email protected]',
pass: 'password',
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: {
name: 'My name',
address: '[email protected]',
}, // sender address
replyTo: '[email protected]',
to: '[email protected]', // 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 [email protected] actually sent the email.
Thanks!
Upvotes: 0
Views: 1174
Reputation: 21
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: '[email protected]',
pass: 'password',
},
});
let info = await transporter.sendMail({
from: {
name: 'My name',
address: '[email protected]',
},
to: '[email protected]',
subject: 'Hello ✔',
text: 'Hello world?',
html: '<b>Hello world?</b>',
});
Upvotes: 2