sklarsa / django-sendgrid-v5

An implementation of Django's EmailBackend compatible with sendgrid-python v5+
MIT License
318 stars 54 forks source link

How to change the Sender Name? #104

Closed KrishnaManohar1997 closed 2 years ago

KrishnaManohar1997 commented 2 years ago

I want to send a specific Sender Name for the email

Is there any setting using which we can customize it? I have checked in the class EmailMessage it doesn't have any parameter to customize the sender_name or from_name

msg = EmailMessage(subject="Test Sender Name", body="Test body for sender name",
            from_email="abc@abc.in",to=["abcgood@gmail.com"])
msg.send()

For Instance, I need the sender name as Support Bot

from_email inside EmailMessage class the from django.core.mail import EmailMessage

I have checked the EmailMessage class it doesn't have a parameter to customize the Sender Name.

sklarsa commented 2 years ago

We use python's built-in email.utils.parseaddr method to parse emails into Name/Address tuples (https://docs.python.org/3/library/email.utils.html#email.utils.parseaddr). This lib accepts RFC 2822 formatted email address, like so: from_email="John Smith <john.smith@example.org>".

Let me know how this works

KrishnaManohar1997 commented 2 years ago

Hey, @sklarsa Thanks for your amazingly immediate response.

The solution is working perfectly, can you also add this to the README.md for other devs to find it easily?

sklarsa commented 2 years ago

https://github.com/sklarsa/django-sendgrid-v5/issues/105