简体   繁体   中英

Using third party Email system for Django Password Reset

I have a Django App hosted on Google Compute Engine(which doesn't allow port 25/465/587 to send Emails). So, I integrated a third party Email system in the Django App. Third party Email system works find on Google Compute Engine too.

But when I use Django Reset Password, that email is still getting sent over by the Django Default Email System. Can this Django Default Email system for password Reset be changed ?

If yes, Can someone please explain how it can be changed ?

Thanks,

There is something like Email backends

# settings.py
EMAIL_BACKEND = 'project.backends.mail.CustomEmailBackend'

# project/backends/mail.py
from django.core.mail.backends.base import BaseEmailBackend
class CustomEmailBackend(BaseEmailBackend):
    def send_messages(self, messages):
        for message in messages:
            # do the stuff with each message
            print(message.subject, message.body, message.to, message.cc)

Remeber that path dotted in EMAIL_BACKEND variable in settings.py must be the same as location of your CustomEmailBackend class in your project folder tree.

Each message has the same properties . Of course send_mail from django.core.mail will work as usuall, but use your CustomEmailBackend for sending emails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM