python
from django.core.mail import send_mail
send_mail(subject, message, from, [to], fail_silently=False, auth_user=ANOTHER_HOST_USER, auth_password=ANOTHER_HOST_PASSWORD)
However, this can only be sent by To.
I want to send it by BCC ~ ~.
send_mail () is also a light wrapper over the EmailMessage class.
python
from django.core.mail import EmailMessage
email = EmailMessage(subject, message, from, [to], [bcc])
email.send(fail_silently=False)
I was able to send it with BCC! !! However, if you do this, it will be sent by EMAIL_HOST_USER in settings.
Normally, send_mail () will open it when you send it, but you should open it yourself.
python
from django.core.mail import EmailMessage, get_connection
connection = get_connection(fail_silently=False, username=ANOTHER_HOST_USER, password=ANOTHER_HOST_PASSWORD)
connection.open()
email = EmailMessage(subject, message, from, [to], [bcc], connection=connection)
email.send()
#If you want to send more than one
# connection.send_messages([email])
#Since it was opened manually, it is also manually closed.
connection.close()
Then, a user other than the user described in settings was able to send the mail of the destination BCC!
Are you wrong? correct? ?? ??
Recommended Posts