15

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
B Robster
  • 40,605
  • 21
  • 89
  • 122
  • Please see this: http://stackoverflow.com/questions/2111452/giving-email-account-a-name-when-sending-emails-with-django-through-google-apps – Mikael Mar 28 '12 at 16:15

5 Answers5

28

You can use

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

as the from address in the call to send_mail.

RotaJota
  • 831
  • 9
  • 14
17

Those solutions are useful if you're using django's email package directly. However, i didn't want to look for a hook to override the way that django-registration uses send_mail so I found the following setting when going through the django files, which lets you set a default from email.

 DEFAULT_FROM_EMAIL='(My Company) Support <no-reply@mycompany.com>' 

and it worked!

Figured someone else may find it useful, although i'm not so pretentious as to mark my own answer as correct.

B Robster
  • 40,605
  • 21
  • 89
  • 122
2

DEFAULT_FROM_EMAIL='(My Company) Support '

Helped me to solve the issue.

user3613331
  • 121
  • 1
  • 6
2

You can use ADMINS and MANAGERS tuples in setting.py. E.g.:

ADMINS = (('Your Name', 'email@company.com),)

And then:

django.core.email.mail_managers('subject', 'body')
nnyby
  • 4,748
  • 10
  • 49
  • 105
0

Another explicit way is to use the Address

read my other answer here

from email.headerregistry import Address

DEFAULT_FROM_EMAIL = Address(display_name="Company Name", addr_spec="info@domain.com")
Art
  • 2,836
  • 4
  • 17
  • 34