I am following this link to send emails from Django using SendGrid. If my email address in cc and to_email is same, it returns HTTP Error 400: Bad Request. But it works fine if the email address is different. Did anyone solve this problem before? I need to add cc while sending an email from Django whether the email address is the same or different. Thanks in advance.
sg = SendGridAPIClient(development.EMAIL_HOST_PASSWORD)
cc_email = str(ImagingCenter.objects.get(institute_id=user.center_id).email)
from_email = development.DEFAULT_FROM_EMAIL
to_email = to_email
data = {
"personalizations": [{
"to": [{
"email": to_email
}],
"cc": [
{
"email": cc_email
}
],
"subject": "CC Email Testing"
}
],
"from": {
"email": from_email
},
"content": [
{
"type": "text/html",
"value": html_message
}
]
}
response = sg.client.mail.send.post(request_body=data)