djangodjango-registration

How to specify name in Django mail?


I am using django's core.mail package in conjunction with django-registration for a new user sign up workflow. I have an email account, "no-reply@(mycompany).com" through my company's google mail service, that i want to use to send these emails. In the google mail account settings i set the name for the email account as "(MyCompany) Support" so that if I mail directly from google mail, the emails come in from the account as being from "(MyCompany) Support ". However, when i use django's email settings to send mail, the emails show up in a client's email box as being from "no-reply" which is ugly and may be a bit off-putting to a new client. Is there a way to specify a "Name" for an email address when sending using django's built-in mailer so that the see the "Name" displayed when they get the email?

Here are my current settings in settings.py:

EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER='no-reply@mycompany.com'
EMAIL_HOST_PASSWORD='**********'
EMAIL_USE_TLS = True

Solution

  • You can use

    "(MyCompany) Support <no-reply@mycompany.com>"
    

    as the from address in the call to send_mail.