Example #1
0
    def send_activation_email(self):
        """
        Sends a activation email to the user.

        This email is send when the user wants to activate their newly created
        user.

        """
        context = {'user': self.user,
                  'without_usernames': settings.BAPH_AUTH_WITHOUT_USERNAMES,
                  'protocol': get_protocol(),
                  'activation_days': settings.BAPH_ACTIVATION_DAYS,
                  'activation_key': self.activation_key,
                  'org': Organization.get_current(),
                  }

        subject = render_to_string('registration/emails/activation_email_subject.txt',
                                   context)
        subject = ''.join(subject.splitlines())

        message = render_to_string('registration/emails/activation_email_message.txt',
                                   context)
        send_mail(subject,
                  message,
                  django_settings.DEFAULT_FROM_EMAIL,
                  [self.user.email, ])
Example #2
0
    def send_confirmation_email(self):
        """
        Sends an email to confirm the new email address.

        This method sends out two emails. One to the new email address that
        contains the ``email_confirmation_key`` which is used to verify this
        this email address with :func:`UserenaUser.objects.confirm_email`.

        The other email is to the old email address to let the user know that
        a request is made to change this email address.

        """
        context = {'user': self.user,
                  'without_usernames': settings.BAPH_AUTH_WITHOUT_USERNAMES,
                  'new_email': self.email_unconfirmed,
                  'protocol': get_protocol(),
                  'confirmation_key': self.email_confirmation_key,
                  'org': Organization.get_current(),
                  }

        # Email to the old address, if present
        subject_old = render_to_string(
            'registration/emails/confirmation_email_subject_old.txt', context)
        subject_old = ''.join(subject_old.splitlines())

        message_old = render_to_string(
            'registration/emails/confirmation_email_message_old.txt', context)
        if self.user.email:
            send_mail(subject_old,
                      message_old,
                      django_settings.DEFAULT_FROM_EMAIL,
                    [self.user.email])

        # Email to the new address
        subject_new = render_to_string(
            'registration/emails/confirmation_email_subject_new.txt', context)
        subject_new = ''.join(subject_new.splitlines())

        message_new = render_to_string(
            'registration/emails/confirmation_email_message_new.txt', context)

        send_mail(subject_new,
                  message_new,
                  django_settings.DEFAULT_FROM_EMAIL,
                  [self.email_unconfirmed, ])