简体   繁体   中英

Django registration signals fails to send new user a mail after activation

I want to send a new registered user an email after filling the signup form. I'm using Django registration (1.0) to handle the signup process. Also I used the simple-backend so that user can get activated immediately after filling the signup form.

I wrote the below codes to send the new user a welcome email after signing up. From the docs the author said we should use the user_activated signals. But after implementing mine, it failed to send the user a welcome mail.

Signals.py

from registration.signals import user_activated
from django.dispatch import receiver
from django.core.mail import send_mail


@receiver(user_activated)
def my_notice(sender, user, request):
    new_person=user.email
    send_mail('Welcome On Board','Check the dashboard for more','example@example.com',[new_person,])

What am I missing?

File signals.py is not read by django. Try in models.py instead.

signals.py file is a good place to define a signal. You're hooking up to one.

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