def post_save_announcement(instance, created, **kwargs): if created: subject = instance.title context = {'announcement': instance} template_name = 'courses/announcement_mail.html' enrollments = Enrollment.objects.filter(course=instance.course, status=1) for enrollment in enrollments: recipient_list = [enrollment.user.email] send_mail_template(subject, template_name, context, recipient_list)
def send_mail(self, course): subject = '[%s] Contact' % course context = { 'name': self.cleaned_data['name'], 'email': self.cleaned_data['email'], 'message': self.cleaned_data['message'], } template_name = 'courses/contact_email.html' send_mail_template(subject, template_name, context, [settings.CONTACT_EMAIL])
def send_mail(self, title): subject = '[%s] Contact' % title context = { 'name': self.cleaned_data['name'], 'email': self.cleaned_data['email'], 'message': self.cleaned_data['message'], } template_name = 'core/contact_email.html' send_mail_template(subject, template_name, context, [settings.EMAIL_HOST_USER])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'accounts/password_reset_mail.html' subject = _('Change your password'), context = { 'reset': reset, } send_mail_template(subject, template_name, context, [user.email])