def send_confirmation(self, email_address): salt = sha_constructor(str(random())).hexdigest()[:5] confirmation_key = sha_constructor(salt + email_address.email).hexdigest() current_site = Site.objects.get_current() # check for the url with the dotted view path try: path = reverse(EMAIL_CONFIRM_VIEW, args=[confirmation_key]) except NoReverseMatch: # or get path with named urlconf instead path = reverse("emailconfirmation_confirm_email", args=[confirmation_key]) protocol = getattr(settings, "DEFAULT_HTTP_PROTOCOL", "http") activate_url = u"%s://%s%s" % ( protocol, unicode(current_site.domain), path ) context = { "user": email_address.user, "activate_url": activate_url, "current_site": current_site, "confirmation_key": confirmation_key, } #subject = render_to_string(settings.EMAIL_CONFIRMATION_SUBJECT, context) subject = settings.EMAIL_CONFIRMATION_SUBJECT # remove superfluous line breaks subject = "".join(subject.splitlines()) message = render_to_string(settings.EMAIL_CONFIRMATION_MESSAGE, context) # launch a new thread to send email, don't let user wait for so long, by junn startEmailSendThread(subject, message, settings.DEFAULT_FROM_EMAIL, [email_address.email]) confirmation = self.create( email_address=email_address, sent=datetime.datetime.now(), confirmation_key=confirmation_key ) email_confirmation_sent.send( sender=self.model, confirmation=confirmation, ) return confirmation
def send_reset_email(self, subject, message, email): startEmailSendThread(subject, message, settings.DEFAULT_FROM_EMAIL, [email])