def send_welcome_mail_callback(sender, instance, created, **kwargs): from django.contrib.auth import get_user_model USER_MODEL = get_user_model() if getattr(settings, "SEND_WELCOME_MAIL") and \ isinstance(instance, USER_MODEL) and created: if valid_email(instance.email): send_welcome_mail(user=instance)
def send_welcome_mail_pipe(strategy, user, response, details, is_new=False, *args, **kwargs): """ The post_save signal handler in bb_accounts.models deals with sending a welcome mail. However, because the User object passes through the social pipeline it gets saved several time and therefore losing the "new" status to trigger sending an email. This pipe in the social pipeline therefore sends an explicit welcome email. """ if is_new and valid_email(user.email): send_welcome_mail(user)