def send_password_reset_email(user): token = user.get_reset_password_token() send_email(subject='[Goose Or Not] Reset Your Password', recipients=[user.email], text_body=render_template_string(reset_password, user=user, token=token))
def test_send_email(app): with mail.record_messages() as outbox: send_email(subject='testing', text_body='test', recipients=['*****@*****.**']) assert (len(outbox) == 1) assert (outbox[0].bcc[0] == '*****@*****.**')
def post(self, request, format=None): user = TallyListEntry.objects.order_by('-created_at')[0].user send_email(MAIL_SENDER, [user.email], "You have been blamed!", render_to_string("mail-blame.txt", { "firstname": user.first_name, "lastname": user.last_name })) return Response({}, status=status.HTTP_204_NO_CONTENT)
def save(self, *args, **kwargs): if not self.pk: self.user.balance -= COFFEE_PRICE * self.amount self.user.save() if self.user.receive_emails: warnings = [] if self.user.balance < 2: warnings.append("Warning: Your account balance is low (%.2f EUR)! Please add some more money to your account." % self.user.balance) send_email(MAIL_SENDER, [self.user.email], "A coffee has been tracked", render_to_string("mail-coffee.txt", { "firstname": self.user.first_name, "lastname": self.user.last_name, "amount": self.amount, "warnings": warnings })) super(TallyListEntry, self).save(*args, **kwargs)