Reputation: 2165
As a owner I have already verify my gmail in sendgrid
, when I sent a message with owner mail account then It has been sent, but when I try to sent mail as a customer with different mail account then show me error like this: That means customer also need to verify their mail account with sendGrid ?
{
errors: [
{
message: 'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements',
field: 'from',
help: null
}
]
}
I don't know why.
I have tried code following this way:
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
exports.contactForm = (req, res) => {
const { email, name, message } = req.body;
const emailData = {
to: process.env.EMAIL_TO,
from: email,
subject: `Contact form - ${process.env.APP_NAME}`,
text: `Email received from contact from \n Sender name: ${name} \n Sender email: ${email} \n Sender message: ${message}`,
html: `
<h4>Email received from contact form:</h4>
<p>Sender name: ${name}</p>
<p>Sender email: ${email}</p>
<p>Sender message: ${message}</p>
<hr />
<p>This email may contain sensetive information</p>
`,
};
sgMail
.send(emailData)
.then(() => {
console.log("Message sent");
})
.catch((error) => {
console.log(error.response.body);
});
};
Any suggestion Please.
Upvotes: 2
Views: 2617
Reputation: 141
Unfortunately, you really can't send emails via SendGrid from unverified emails. To do this - you need to use another one email service, for example, i used SendInBlue to do this (upd: SendInBlue changed name and now they are Brevo)
Upvotes: 1
Reputation: 108651
Sendgrid (along with other bulk email vendors) requires you to send every email messages From: a well-known address. You may not send mail via Sendgrid so it looks to the recipient like it came from an arbitrary unverified email account.
Why not? Spam.
Companies like Sendgrid go to a lot of trouble to prevent their customers from using their services to send spam messages. If they let their customers send spam messages, their servers would be blocked by gmail, outlook, and the other big email providers, and would appear in the anti-spam blocklists used by smaller email providers. If that happened it would quickly wreck their business.
So, any email account you claim as the From address in a Sendgrid message must be verified.
Upvotes: 1