Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone had success getting Django to send emails when hosting on Dreamhost?

Greetings,

Does anyone know what are the required fields to have Django send emails when a "500 Internal Server Error" happend? I am hosting my project on Dreamhost and for the life of me I can't get Django to send emails. What are the required fields when hosting on Dreamhost?

like image 210
letsgofast Avatar asked Dec 21 '09 06:12

letsgofast


People also ask

Can Django send emails?

Django ships with several email sending backends. With the exception of the SMTP backend (which is the default), these backends are only useful during testing and development. If you have special email sending requirements, you can write your own email backend.

How does Django get email?

With Django Admin Go to Django Admin, then to 'Mailboxes' page, check all the mailboxes you need to receive emails from. At the top of the list with mailboxes, choose the action selector 'Get new mail' and click 'Go'.


2 Answers

As proposed by S.Mark, you can use gmail. Here is what you need in your settings.py

ADMINS = (
    ('Your Name', '[email protected]'),
)

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_PASSWORD = 'password'
EMAIL_HOST_USER = 'gmail_account'
EMAIL_SUBJECT_PREFIX = 'something'
EMAIL_USE_TLS = True
like image 63
luc Avatar answered Sep 22 '22 07:09

luc


Yes, I am, same on dreamhost, but I am using gmail to send email like following sample code

import smtplib

m = smtplib.SMTP("smtp.gmail.com", 587)
m.ehlo()
m.starttls()
m.ehlo()
m.login(USERNAME, PASSWD)
m.sendmail(user, to, "From: %s\nTo: %s\n\nHello World!"%(USERNAME,TOADDR))
m.close()
like image 26
YOU Avatar answered Sep 22 '22 07:09

YOU