def send_notification_to_giver(self): if self.order.giver is None: return if self.order.desired_shipment_date is None: return send_mail.delay( to=self.order.giver.email, template_id='gift-notification-for-giver', # postmark disable_antispam=True, ctx={ 'item_name': self.order.item.full_name, 'receiver_name': str(self.order.user), 'receiver_email': self.order.user.email, 'desired_shipment_date': self.order.desired_shipment_date.strftime('%d.%m.%Y'), }, ) self.order.notification_to_giver_is_sent = True self.order.save()
def register(): if current_user.is_authenticated: return redirect(url_for("core.index")) form = RegistrationForm(request.form) if form.validate_on_submit(): user = User(display_name=form.display_name.data, email=form.email.data) user.set_password(form.password.data) send_mail.delay( recipient=user.email, subject="Mail Verification", template="messages/verification.html", context={ "user": user.display_name, "verification_code": user.generate_verification_code(), }, ) db.session.add(user) db.session.commit() flash(_("Congratulations, you are now a registered user!"), "success") flash( _("Remember to verify your email address to make full use of Talks.Tue!" ), "warning", ) current_app.logger.info(f"New user registered: {user}") return redirect(url_for("auth.login")) return render_template("auth/register.html", title="Register", form=form)
def send_mail_to_user(self, user: User): send_mail.delay( to=user.email, template_id='new-answer-notification', ctx=self.get_notification_context(user), disable_antispam=True, )
def send_welcome_letter(self): if self.course.welcome_letter_template_id is not None and len( self.course.welcome_letter_template_id): send_mail.delay( to=self.user.email, template_id=self.course.welcome_letter_template_id, ctx=self.get_template_context(), )
def send_welcome_letter(self): if self.welcome_letter_template_id is not None: send_mail.delay( to=self.user.email, template_id=self.welcome_letter_template_id, ctx=self.get_template_context(), disable_antispam=True, )
def notify_users(self): for user in self.get_users_to_notify(): user_checks_list = self.get_checks_for_user(user) send_mail.delay( to=user.email, template_id='new-answers-to-check', ctx=self.get_notification_context(user_checks_list), disable_antispam=True, )
def test_antispam_arg_is_passed_via_task(disable_antispam, should_email_be_sent): EmailLogEntry.objects.create(email='*****@*****.**', template_id=100500) send_mail.delay(to='*****@*****.**', template_id=100500, disable_antispam=disable_antispam) assert (len(mail.outbox) == 1) is should_email_be_sent
def send_to_student(self): send_mail.delay( to=self.study.student.email, template_id='new-diploma', ctx=dict( course_name=self.study.course.full_name, diploma_url=self.get_absolute_url(), ), disable_antispam=True, )
def execute(self, user: User): send_mail.delay( to=user.email, template_id=self.template_id, ctx={ 'campaign_name': self.name, 'firstname': user.first_name, 'lastname': user.last_name, }, disable_antispam=True, )
def get(self, request, user_email: str): user = User.objects.filter(email=user_email).first() if user is not None: token = PasswordlessAuthToken.objects.create(user=user) send_mail.delay( to=user.email, template_id='passwordless-token', ctx=dict( name=str(user), action_url=token.get_absolute_url(), ), disable_antispam=True, ) return Response({'ok': True})
def send_record_link(self): """Send email, convinience method for subclasses The mail is not sent by default, you have to call it manualy! """ return send_mail.delay( to=self.user.email, template_id=self.get_template_id(), ctx=self.get_template_context(), )
def reverify(): send_mail.delay( recipient=current_user.email, subject="Mail Verification", template="messages/verification.html", context={ "user": current_user.display_name, "verification_code": current_user.generate_verification_code(), }, ) db.session.commit() flash( _("Remember to verify your email address to make full use of Talks.Tue!" ), "warning", ) next = request.args.get("next") if not is_safe_url(next): return abort(400) else: next = next or url_for("core.index") return redirect(next)
def send(self): send_mail.delay( template_id=self.template_id, to=self.order.user.email, ctx=self.get_template_context(), )
def send_email_to_all_purchased_users(self, template_id: str): for user in self.get_purchased_users().iterator(): send_mail.delay( to=user.email, template_id=template_id, )