Derek Derek - 1 year ago 69
Python Question

How to send email via Django?

In my
, I have the following:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# Host for sending e-mail.
EMAIL_HOST = 'localhost'

# Port for sending e-mail.

# Optional SMTP authentication information for EMAIL_HOST.

My email code:

from django.core.mail import EmailMessage
email = EmailMessage('Hello', 'World', to=[''])

Of course, if I setup a debugging server via
python -m smtpd -n -c DebuggingServer localhost:1025
, I can see the email in my terminal.

However, how do I actually send the email not to the debugging server but to

After reading your answers, let me get something straight:

  1. Can't you use localhost(simple ubuntu pc) to send e-mails?

  2. I thought in django 1.3 send_mail() is somewhat deprecated and EmailMessage.send() is used instead?

Answer Source

Send the email to a real SMTP server. If you don't want to set up your own then you can find companies that will run one for you, such as Google themselves.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download