0

This exact code works in the shell, but does not work in my view and I have no idea why. There is no error message. The email just never gets sent.

from django.core.mail import send_mail

send_mail('Account Created','Your account has been created!',
                    'info@mysite.com',[request.user.email])

settings.py - email settings

ALLOWED_HOSTS = []
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#SERVER_EMAIL = 'email@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_HOST_USER = 'postmaster@mg.mysite.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
user10421193
  • 217
  • 2
  • 11
  • It works in the shell, so presumably there is nothing wrong with my email settings, but I will add them. – user10421193 Sep 21 '19 at 18:16
  • 2
    When you say it works on the shell, is that the same host that the Django server is running on? How have you confirmed that `request.user.email` is correct? Have you checked mailgun logs? – Alasdair Sep 21 '19 at 18:26

0 Answers0