It has been just 1½ weeks since I setup my free email API account on Sendgrid, & I have sent only ~12 emails ever since (to my family members for testing purposes). I have a fully verified single sender for my personal email address [email protected]
and I am using the same to send the email through API.
Here's the cURL API I built, to send an email to 4 addresses using a dynamic template -
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'authorization: Bearer <MY_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"personalizations": [
{
"to": [{"email": "[email protected]"}],
"dynamic_template_data": {"first_name": "xxxxxxxx","date": "9th Nov. 2021","city": "Mumbai"}
},
{
"to": [{"email": "[email protected]"}],
"dynamic_template_data": {"first_name": "xxxxxxxx","date": "27th Oct. 2021","city": "Mumbai"}
},
{
"to": [{"email": "[email protected]"}],
"dynamic_template_data": {"first_name": "xxxxxxxx","date": "9th Jun. 2021","city": "Mumbai"}
},
{
"to": [{"email": "[email protected]"}],
"dynamic_template_data": {"first_name": "xxxxxxxx","date": "21st Oct. 2021","city": "Mumbai"}
}
],
"from": {"email": "[email protected]", "name":"xxxxxxxx"},
"template_id" : "<MY_TEMPLATE_ID>"
}'
The email is sent perfectly to all the four recipients, except it ends up in spam for all four of them. Since my account is pretty much new, and I have barely sent any emails (and for the ones I sent, no one marked them as spam/etc.), I wonder what's causing my sent emails to end up in Spam... Is there something wrong in the API I built? Is sending to multiple people causing this?
Please guide me. Thanks!
CodePudding user response:
Twilio SendGrid developer evangelist here.
It appears that you have verified a Gmail address as a single sender and you are sending emails to other Gmail addresses.
Verifying as single sender lets SendGrid know that you own the email address, but it does not help to prove that to other inboxes. In this case, you are sending from a Gmail address to a Gmail address, and such Gmail knows 100% that Gmail did not send the email in the first place. Since Gmail did not send the email from the Gmail address, it seems to Gmail that it is spam, regardless of the content.
Using Single Sender Verification is good for testing your code, but it is not recommended for production use. To give yourself a better chance of not ending up in spam inboxes we recommend Domain Authentication. Domain Authentication also sets up SPF and DKIM, and can set you on the path to DMARC, all of which give your email address sender better reputation.