[Answered ]-How to use two different email addresses for emails sending?

2👍

You can override the settings in your settings.py by using get_connection like this

from django.core.mail import get_connection, send_mail
from django.core.mail.message import EmailMessage

with get_connection(
    host=<host>, 
    port=<port>, 
    username=<username>, 
    password=<password>, 
    use_tls=<True/False>
) as connection:
    EmailMessage(subject, body, from, [to],
                 connection=connection).send()

Using with will close the connection automatically. If you don’t use with you’ll need to close the connection manually with connection.close()

Documentation is here -> https://docs.djangoproject.com/en/dev/topics/email/#email-backends

👤Colwin

Leave a comment