Using gmail to send e-mails from Django
Tosendane-mailthroughdjango'sSMTPserveryoujusthavetodefineafewvariablesinyoursettings.py
EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = '[email protected]' EMAIL_HOST_PASSWORD = 'pw' EMAIL_PORT = 587 EMAIL_USE_TLS = True
Youcantesttomakesureyoursettingsworkproperlybyloadingupthepythoninterpreter:
$> ./manage.py shell from django.core.mail import EmailMessage email = EmailMessage('Subject', 'Body', to=['[email protected]']) email.send()
IfyoudefineawrongEMAIL_HOSTlike'gmail.com'insteadof'smtp.gmail.com'email.send()willjustsitthereandchurnandnotgiveyouaresponseback.