Skip to content

Instantly share code, notes, and snippets.

@leonardotrp
Last active March 8, 2019 00:24
Show Gist options
  • Select an option

  • Save leonardotrp/ea6546b43c3c9da8f9017aa12c14ba36 to your computer and use it in GitHub Desktop.

Select an option

Save leonardotrp/ea6546b43c3c9da8f9017aa12c14ba36 to your computer and use it in GitHub Desktop.
Send mail with custom EMAIL_FROM
from mailing import mail
def send():
mail.send_email(recipients=[[email protected]], \
subject='[Test Email] Subject', \
text_content='This is a test', \
from_email=settings.DEFAULT_FROM_EMAIL)
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
# https://pypi.org/project/django-mailing/
DEFAULT_FROM_EMAIL = 'noreply@app'
MAILING_USE_CELERY = True
@leonardotrp
Copy link
Author

I have a Django 1.8 application and it uses Celery for multiprocessing. My problem is that I can not make mail.send_message (...) use the settings.DEFAULT_EMAIL_FROM property, instead of settings.EMAIL_HOST_USER

  • I'm using the djcelery_mail backend
  • I have already tested using both django.core.mail and django_mailing package.

How do I personalize the sender's email?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment