def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.clothing_ordering_enabled: return HttpResponseForbidden() super_return = super().form_valid(form) person = form.person orders = '\n'.join(o.info() for o in Order.get_current(person=person)) if orders == "": orders = _("Keine Bestellungen") email = EmailMessage() ophase_current = Ophase.current() email.subject = _("Kleiderbestellung %(ophase)s") % {'ophase': str(ophase_current)} email_template = loader.get_template('clothing/mail/order.txt') email.body = email_template.render({ 'name': person.prename, 'orders': orders, 'editurl': self.request.build_absolute_uri(reverse('clothing:overview')) }) email.to = [person.email] email.reply_to = [ophase_current.contact_email_address] email.send() return super_return
def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.workshop_submission_enabled: return HttpResponseForbidden() context = self.get_context_data() form_content = '' for field in form.fields: form_content += "{}: {}\n".format(form[field].label, form.cleaned_data[field]) email = EmailMessage() email.subject = _("Workshop in der %(ophase)s") % {'ophase': context['ophase_title']} email_template = loader.get_template('workshops/mail/submission.txt') email.body = email_template.render({ 'name': form.cleaned_data['tutor_name'], 'title': form.cleaned_data['title'], 'ophase': context['ophase_title'], 'form_content': form_content }) email.to = [form.cleaned_data['tutor_mail']] if settings is not None: email.reply_to = [settings.orga_email] email.send() return super().form_valid(form)
def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.workshop_submission_enabled: return HttpResponseForbidden() context = self.get_context_data() form_content = '' for field in form.fields: form_content += "{}: {}\n".format(form[field].label, form.cleaned_data[field]) email = EmailMessage() email.subject = _("Workshop in der %(ophase)s") % { 'ophase': context['ophase_title'] } email_template = loader.get_template('workshops/mail/submission.txt') email.body = email_template.render({ 'name': form.cleaned_data['tutor_name'], 'title': form.cleaned_data['title'], 'ophase': context['ophase_title'], 'form_content': form_content }) email.to = [form.cleaned_data['tutor_mail']] if settings is not None: email.reply_to = [settings.orga_email] email.send() return super().form_valid(form)
def send_notification( sender, subject, mail_content, template_name, recipient_list, cc_list, bcc_list, reply_to=None): """ send notification :param sender: :param subject: :param mail_content: :param template_name: :param recipient_list: :param cc_list: :param bcc_list: :param reply_to: """ template = get_template(template_name) ctx = Context({'request': mail_content}) message = template.render(ctx) email = EmailMessage(subject=subject, body=message, from_email=sender, to=recipient_list) if cc_list: email.cc = cc_list if bcc_list: email.bcc = bcc_list if reply_to: email.reply_to = reply_to email.send()
def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.clothing_ordering_enabled: return HttpResponseForbidden() super_return = super().form_valid(form) person = form.person orders = '\n'.join(o.info() for o in Order.get_current(person=person)) if orders == "": orders = _("Keine Bestellungen") email = EmailMessage() ophase_current = Ophase.current() email.subject = _("Kleiderbestellung %(ophase)s") % { 'ophase': str(ophase_current) } email_template = loader.get_template('clothing/mail/order.txt') email.body = email_template.render({ 'name': person.prename, 'orders': orders, 'editurl': self.request.build_absolute_uri(reverse('clothing:overview')) }) email.to = [person.email] email.reply_to = [ophase_current.contact_email_address] email.send() return super_return
def contact(request): context=getContext() # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = ContactForm(request.POST) # check whether it's valid: if form.is_valid(): message = EmailMessage() message.subject = "[{} via website]".format(form.cleaned_data["your_name"])+form.cleaned_data["subject"] message.reply_to = [form.cleaned_data["sender"]] message.to=[TO] message.body = form.cleaned_data["message"] if form.cleaned_data["copy_myself"]: message.cc=[form.cleaned_data["sender"]] message.send() return HttpResponseRedirect('/personal/thanks/') else: context.update({'form': form, "errors": True}) return render(request, 'personal/contact.htm', context) # if a GET (or any other method) we'll create a blank form else: form = ContactForm() context.update({'form': form}) return render(request, 'personal/contact.htm', context)
def send_email(from_email, to_email, body, subject, reply_to): email = EmailMessage() email.subject = subject email.body = body email.from_email = from_email email.to = [ to_email, ] if reply_to: email.reply_to = [ reply_to, ] else: email.reply_to = [ from_email, ] email.send()
def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.any_registration_enabled(): return HttpResponseForbidden() try: if form.instance.tutor_experience is None: form.instance.tutor_experience = 0 super_return = super().form_valid(form) except IntegrityError: # this should happen when unique constraints fail template = loader.get_template("staff/already_registered.html") return TemplateResponse(self.request, template) # the enumeration symbol esym = '\n * ' form_list = [] for field in form.fields: label = form[field].label # remove html from label label = label.split('<', 1)[0].strip() content = form.cleaned_data[field] #Remove all fields that are not set if content: #format Many to Many and foreign key if isinstance(content, QuerySet): content = esym + esym.join(str(c) for c in content) #format True as normal language if isinstance(content, bool): content = _('Ja') form_list.append('{}: {}'.format(label, content)) form_content = '\n'.join(form_list) values = { 'ophase_title': str(Ophase.current()), 'user_prename': form.cleaned_data['prename'], 'user_name': form.cleaned_data['name'], 'user_email': form.cleaned_data['email'], 'email_changedata': Ophase.current().contact_email_address, 'form_content': form_content, } email = EmailMessage() email.subject = _('{ophase_title} Registrierung').format(**values) email.to = [ '{user_prename} {user_name} <{user_email}>'.format(**values) ] email_template = loader.get_template('staff/mail/register.txt') email.body = email_template.render(values) email.reply_to = [Ophase.current().contact_email_address] email.send() return super_return
def send( self, to, context, lang = None, attachements = [], reply_to = None ): # This is the major method of this module. if lang != 'de': subj_en, en = self.get_english_text( context ) if lang != 'en': subj_de, de = self.get_german_text( context ) if not lang: # make multilang-mail body = '''[english text below] {} ---------------------------------------------------------------------- {}'''.format(de, en) subj = "{} | {}".format(subj_de, subj_en) elif lang =='de': body = de subj = subj_de else: body = en subj = subj_en # Make sure `to` is a list if isinstance(to, str): to = [ to ] wrapped_body = wrap( body ) email = EmailMessage( subj, wrapped_body, settings.RUBION_MAIL_FROM, to ) if reply_to is not None: email.reply_to = reply_to for attachment in attachements: email.attach_file(attachment) email.send(fail_silently = False) mail = SentMail() mail.sender = settings.RUBION_MAIL_FROM try: mail.to = ', '.join(to) except TypeError: mail.to = str(to) mail.subject = subj mail.body = wrapped_body mail.save() return mail
def form_valid(self, form): settings = Settings.instance() if settings is None or not settings.any_registration_enabled(): return HttpResponseForbidden() try: if form.instance.tutor_experience is None: form.instance.tutor_experience = 0 super_return = super().form_valid(form) except IntegrityError: # this should happen when unique constraints fail template = loader.get_template("staff/already_registered.html") return TemplateResponse(self.request, template) # the enumeration symbol esym = '\n * ' form_list = [] for field in form.fields: label = form[field].label # remove html from label label = label.split('<', 1)[0].strip() content = form.cleaned_data[field] #Remove all fields that are not set if content: #format Many to Many and foreign key if isinstance(content, QuerySet): content = esym + esym.join(str(c) for c in content) #format True as normal language if isinstance(content, bool): content = _('Ja') form_list.append('{}: {}'.format(label, content)) form_content = '\n'.join(form_list) values = {'ophase_title': str(Ophase.current()), 'user_prename': form.cleaned_data['prename'], 'user_name': form.cleaned_data['name'], 'user_email': form.cleaned_data['email'], 'email_changedata': Ophase.current().contact_email_address, 'form_content': form_content, } email = EmailMessage() email.subject = _('{ophase_title} Registrierung').format(**values) email.to = ['{user_prename} {user_name} <{user_email}>'.format(**values)] email_template = loader.get_template('staff/mail/register.txt') email.body = email_template.render(values) email.reply_to = [Ophase.current().contact_email_address] email.send() return super_return
def send_mail(context_dict, template_prefix, to=[], reply_to=None, from_email=settings.DEFAULT_FROM_EMAIL): context = Context(context_dict) template_prefix_dict = {'template_prefix': template_prefix} template_body = get_template('mails/%(template_prefix)s_body.html' % template_prefix_dict) body = template_body.render(context) template_subject= get_template('mails/%(template_prefix)s_subject.html' % template_prefix_dict) subject = template_subject.render(context).replace('\n', '').replace('\r', '') email = EmailMessage(subject, body, from_email, to) if reply_to is not None: email.reply_to = [reply_to] email.send()
def form_valid(self, form): email = form.cleaned_data.get('email') text = form.cleaned_data.get('message') mail = EmailMessage() mail.subject = settings.MAIL_CONTACTFORM_SUBJECT mail.body = settings.MAIL_CONTACTFORM_TEXT % { 'sender': email, 'text': text } mail.to = [settings.SERVER_EMAIL] mail.reply_to = [email,] mail.send() return super(ContactView, self).form_valid(form)
def send_mail(context_dict, template_prefix, to=[], reply_to=None, from_email=settings.DEFAULT_FROM_EMAIL): validated_to = [] for m in to: if validateEmail(m): validated_to.append(m) to = validated_to context = Context(context_dict) template_prefix_dict = {'template_prefix': template_prefix} template_body = get_template('mails/%(template_prefix)s_body.html' % template_prefix_dict) body = template_body.render(context) template_subject = get_template('mails/%(template_prefix)s_subject.html' % template_prefix_dict) subject = template_subject.render(context).replace('\n', '').replace('\r', '') email = EmailMessage(subject, body, from_email, to) if reply_to is not None: email.reply_to = [reply_to] email.send()
def __send_plain(self): """ Get plain content for email and send message :return: boolean """ plain_content = self.__render_template( self.config['templates']['plain']) if plain_content: email = EmailMessage( self.config['subject'], plain_content, self.config['from_email'], self.config['recipient'], ) if self.config['reply_to']: email.reply_to = self.config['reply_to'] return self.__deliver(email) return False
def send_mail(self): email = EmailMessage() if self.email_subject: email.subject = self.email_subject if self.email_to: email.to = [x.strip() for x in self.email_to.split(',')] if self.email_cc: email.cc = [x.strip() for x in self.email_cc.split(',')] if self.email_bcc: email.bcc = [x.strip() for x in self.email_bcc.split(',')] if self.email_reply_to: email.reply_to = [ x.strip() for x in self.email_reply_to.split(',') ] if self.email_msg: email.body = self.email_msg return email.send(fail_silently=False)
def form_valid(self, form): """ Send email with cleaned_data from form """ email = EmailMessage() contact_name = form.cleaned_data['name'] contact_email = form.cleaned_data['email'] contact_message = form.cleaned_data['message'] # Set up the EmailMessage object email.body = self.MESSAGE_TEMPLATE.format(contact_name, contact_email, contact_message) email.to = [ settings.CONTACT_EMAIL ] email.subject = settings.CONTACT_SUBJECT email.from_email = settings.CONTACT_SENDER email.reply_to = [ form.cleaned_data['email'] ] email.send() return super().form_valid(form)
def send_email_attachment(self, files): email = EmailMessage() if self.email_subject: email.subject = self.email_subject if self.email_to: email.to = [x.strip() for x in self.email_to.split(',')] if self.email_cc: email.cc = [x.strip() for x in self.email_cc.split(',')] if self.email_bcc: email.bcc = [x.strip() for x in self.email_bcc.split(',')] if self.email_reply_to: email.reply_to = [ x.strip() for x in self.email_reply_to.split(',') ] if self.email_msg: email.body = self.email_msg for file in files: email.attach(file.name, file.read(), file.content_type) return email.send(fail_silently=False)
def contact_ajax(request): if request.method == 'POST': form = SettingsForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] message = form.cleaned_data['message'] email = form.cleaned_data['email'] subject = "[Contact Form] Demande de " + name # create the email email_msg = EmailMessage() email_msg.subject = subject email_msg.body = message email_msg.from_email = email email_msg.to = [settings.EMAIL_HOST_USER] email_msg.reply_to = [email] # send it email_msg.send() else: form = SettingsForm(request.POST) html = render_to_string('form.html', {'form': form}) return HttpResponse(html)
def send_email(self): full_name = self.cleaned_data['full_name'] subject = ("Message de " + full_name + " " "envoyé depuis le formulaire de contact") message = self.cleaned_data['message'] from_email = '{full_name} <{email}>'.format( full_name=full_name, email=settings.EMAIL_SENDER) recipient_list = [settings.EMAIL_RECIPIENT] reply_to_list = [self.cleaned_data['email']] email = EmailMessage(subject, message) email.subject = subject email.body = message email.from_email = from_email email.to = recipient_list email.reply_to = reply_to_list try: email.send() except: return False return True
def send_email( recipient, subject, content, from_name=None, from_email=None, reply_to=None, force_send=False, connection=None, ): """Generic service to send email from the application""" if not force_send and os.environ.get("ONTASK_DEMO"): raise Exception("Email sending is disabled in the demo") from_name = from_name if from_name else EMAIL_NAME if not from_email: from_email = EMAIL_ALIAS if EMAIL_ALIAS else EMAIL_HOST_USER if from_name: from_email = f"{from_name} <{from_email}>" # If a batch of emails are being sent, then use the provided connection # Rather than opening a connection for each email sent in the batch # Refer to https://docs.djangoproject.com/en/2.1/topics/email/#email-backends email = EmailMessage(subject, content, from_email, [recipient], connection=connection) email.content_subtype = "html" if reply_to: email.reply_to = [reply_to] email.send() return True
def send_email(self, request): if request.session.get('deerconnect_mailsent',False): last_message = dateparse.parse_datetime(request.session.get('deerconnect_mailsent',False)) expiration = datetime.timedelta(days=1) if last_message > timezone.now() - expiration: return False sender_name = bleach.clean(self.cleaned_data['name'], tags=[], strip=True) sender_addr = bleach.clean(self.cleaned_data['email'], tags=[], strip=True) msg = EmailMessage() msg.subject = '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, bleach.clean(self.cleaned_data['subject'], tags=[], strip=True)) msg.reply_to = [sender_addr,] msg.from_email = '%s <%s>' % (sender_name, settings.DEFAULT_FROM_EMAIL) message_template = get_template('deerconnect/email.txt') message_body = bleach.clean(self.cleaned_data['body'], tags=[], strip=True) message_context = { 'message': message_body, 'IP': request.META.get('REMOTE_ADDR'), 'domain': request.META.get('HTTP_HOST'), 'name': sender_name, 'email': sender_addr, 'subject': msg.subject, } msg.body = message_template.render(message_context) msg.to = [settings.DEERCONNECT_TO_EMAIL,] success = msg.send() if success: request.session['deerconnect_mailsent'] = str(timezone.now()) request.session['deerconnect_success_msg'] = True return True else: return False
def update_grade_data_from_grading_form_v2(self, request, page_context, page_data, grade_data, grading_form, files_data): if grade_data is None: grade_data = {} for k in self.grade_data_attrs: if k == "grade_percent": grade_data[k] = grading_form.cleaned_percent() else: grade_data[k] = grading_form.cleaned_data[k] if grading_form.cleaned_data["notify"] and page_context.flow_session: with translation.override(settings.RELATE_ADMIN_EMAIL_LOCALE): from django.template.loader import render_to_string from course.utils import will_use_masked_profile_for_email staff_email = [ page_context.course.notify_email, request.user.email ] message = render_to_string( "course/grade-notify.txt", { "page_title": self.title(page_context, page_data), "course": page_context.course, "participation": page_context.flow_session.participation, "feedback_text": grade_data["feedback_text"], "flow_session": page_context.flow_session, "review_uri": page_context.page_uri, "use_masked_profile": will_use_masked_profile_for_email(staff_email) }) from django.core.mail import EmailMessage msg = EmailMessage( string_concat("[%(identifier)s:%(flow_id)s] ", _("New notification")) % { 'identifier': page_context.course.identifier, 'flow_id': page_context.flow_session.flow_id }, message, getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM", page_context.course.get_from_email()), [page_context.flow_session.participation.user.email]) msg.bcc = [page_context.course.notify_email] if grading_form.cleaned_data["may_reply"]: msg.reply_to = [request.user.email] if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"): from relate.utils import get_outbound_mail_connection msg.connection = get_outbound_mail_connection( "grader_feedback") msg.send() if (grading_form.cleaned_data["notes"] and grading_form.cleaned_data["notify_instructor"] and page_context.flow_session): with translation.override(settings.RELATE_ADMIN_EMAIL_LOCALE): from django.template.loader import render_to_string from course.utils import will_use_masked_profile_for_email staff_email = [ page_context.course.notify_email, request.user.email ] message = render_to_string( "course/grade-internal-notes-notify.txt", { "page_title": self.title(page_context, page_data), "course": page_context.course, "participation": page_context.flow_session.participation, "notes_text": grade_data["notes"], "flow_session": page_context.flow_session, "review_uri": page_context.page_uri, "sender": request.user, "use_masked_profile": will_use_masked_profile_for_email(staff_email) }) from django.core.mail import EmailMessage msg = EmailMessage( string_concat("[%(identifier)s:%(flow_id)s] ", _("Grading notes from %(ta)s")) % { 'identifier': page_context.course.identifier, 'flow_id': page_context.flow_session.flow_id, 'ta': request.user.get_full_name() }, message, getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM", page_context.course.get_from_email()), [page_context.course.notify_email]) msg.bcc = [request.user.email] msg.reply_to = [request.user.email] if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"): from relate.utils import get_outbound_mail_connection msg.connection = get_outbound_mail_connection( "grader_feedback") msg.send() return grade_data
def get_message(detention, override_recipients=[]): subject = get_subject(detention) body = get_body(detention) detention_mailer = DetentionMailer.objects.get() student = detention.student academic_year = AcademicYear.objects.current() #May throw an exception, which is what we want if we can't get an enrollment - let it fly up enrollment = Enrollment.objects.get(student=student, academic_year=detention.term.academic_year) advisor = enrollment.advisor tutor = enrollment.tutor assigner = detention.teacher message = EmailMessage() message.subject = subject message.body = body from_name = detention_mailer.from_name from_email = detention_mailer.from_email message.from_email = email.utils.formataddr((from_name, from_email)) message.to = [] message.cc = [] message.bcc = [] message.reply_to = [] detention_to_objects = DetentionTo.objects.filter(mailer=detention_mailer) for detention_to_object in detention_to_objects: family_id_key = detention_to_object.family_id_key parent_code = detention_to_object.parent_code try: relation = StudentParentRelation.objects.get(student=detention.student, family_id_key=family_id_key, parent_code=parent_code) if relation.parent.email and relation.parent.email not in message.to: message.to.append(relation.parent.email) except StudentParentRelation.DoesNotExist: pass for additional_address in DetentionCC.objects.filter(mailer=detention_mailer): address = additional_address.address mail_type = additional_address.mail_type #message.to, message.cc, message.bcc mail_list = getattr(message, mail_type) if address not in mail_list: mail_list.append(address) if detention_mailer.advisor_mail and advisor: #message.to, message.cc, etc mail_list = getattr(message, detention_mailer.advisor_mail) address = advisor.email if not address in mail_list: mail_list.append(address) if detention_mailer.tutor_mail and tutor: mail_list = getattr(message, detention_mailer.tutor_mail) address = tutor.email if not address in mail_list: mail_list.append(address) if detention_mailer.assigner_mail and assigner: mail_list = getattr(message, detention_mailer.assigner_mail) address = assigner.email if not address in mail_list: mail_list.append(address) if detention_mailer.reply_to_from: #This was set above message.reply_to.append(message.from_email) if detention_mailer.reply_to_advisor and advisor and advisor.email: advisor_addr = email.utils.formataddr((advisor.name, advisor.email)) if not advisor_addr in message.reply_to: message.reply_to.append(advisor_addr) if detention_mailer.reply_to_tutor and tutor and tutor.email: tutor_addr = email.utils.formataddr((tutor.name, tutor.email)) if not tutor_addr in message.reply_to: message.reply_to.append(tutor_addr) if detention_mailer.reply_to_assigner and assigner and assigner.email: assigner_addr = email.utils.formataddr((assigner.name, assigner.email)) if not assigner_addr in message.reply_to: message.reply_to.append(assigner_addr) #Fix up the recipients - make sure someone isn't in multiple recipient lists. #We've already checked when adding that one person isn't in a recipient list twice. for to_person in message.to: #Remove from both cc and bcc for mail_list in [message.cc, message.bcc]: while to_person in mail_list: mail_list.remove(to_person) for cc_person in message.cc: #Remove CC from BCC while cc_person in message.bcc: message.bcc.remove(cc_person) #BCC can cascade down and does not need any special processing. if override_recipients: ammendment_context = Context({ 'to_addresses': message.to, 'cc_addresses': message.cc, 'bcc_addressses': message.bcc }) ammendment_body = get_template('detention_notifier/sample_ammendment.txt').render(ammendment_context) message.body = message.body + ammendment_body message.to = override_recipients message.cc = [] message.bcc = [] return message
def update_grade_data_from_grading_form_v2(self, request, page_context, page_data, grade_data, grading_form, files_data): if grade_data is None: grade_data = {} for k in self.grade_data_attrs: if k == "grade_percent": grade_data[k] = grading_form.cleaned_percent() else: grade_data[k] = grading_form.cleaned_data[k] if grading_form.cleaned_data["notify"] and page_context.flow_session: from course.utils import LanguageOverride with LanguageOverride(page_context.course): from relate.utils import render_email_template from course.utils import will_use_masked_profile_for_email staff_email = [page_context.course.notify_email, request.user.email] message = render_email_template("course/grade-notify.txt", { "page_title": self.title(page_context, page_data), "course": page_context.course, "participation": page_context.flow_session.participation, "feedback_text": grade_data["feedback_text"], "flow_session": page_context.flow_session, "review_uri": page_context.page_uri, "use_masked_profile": will_use_masked_profile_for_email(staff_email) }) from django.core.mail import EmailMessage msg = EmailMessage( string_concat("[%(identifier)s:%(flow_id)s] ", _("New notification")) % {'identifier': page_context.course.identifier, 'flow_id': page_context.flow_session.flow_id}, message, getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM", page_context.course.get_from_email()), [page_context.flow_session.participation.user.email]) msg.bcc = [page_context.course.notify_email] if grading_form.cleaned_data["may_reply"]: msg.reply_to = [request.user.email] if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"): from relate.utils import get_outbound_mail_connection msg.connection = get_outbound_mail_connection("grader_feedback") msg.send() if (grading_form.cleaned_data["notes"] and grading_form.cleaned_data["notify_instructor"] and page_context.flow_session): from course.utils import LanguageOverride with LanguageOverride(page_context.course): from relate.utils import render_email_template from course.utils import will_use_masked_profile_for_email staff_email = [page_context.course.notify_email, request.user.email] use_masked_profile = will_use_masked_profile_for_email(staff_email) if use_masked_profile: username = ( page_context.flow_session.user.get_masked_profile()) else: username = ( page_context.flow_session.user.get_email_appellation()) message = render_email_template( "course/grade-internal-notes-notify.txt", { "page_title": self.title(page_context, page_data), "username": username, "course": page_context.course, "participation": page_context.flow_session.participation, "notes_text": grade_data["notes"], "flow_session": page_context.flow_session, "review_uri": page_context.page_uri, "sender": request.user, }) from django.core.mail import EmailMessage msg = EmailMessage( string_concat("[%(identifier)s:%(flow_id)s] ", _("Grading notes from %(ta)s")) % {'identifier': page_context.course.identifier, 'flow_id': page_context.flow_session.flow_id, 'ta': request.user.get_full_name() }, message, getattr(settings, "GRADER_FEEDBACK_EMAIL_FROM", page_context.course.get_from_email()), [page_context.course.notify_email]) msg.bcc = [request.user.email] msg.reply_to = [request.user.email] if hasattr(settings, "GRADER_FEEDBACK_EMAIL_FROM"): from relate.utils import get_outbound_mail_connection msg.connection = get_outbound_mail_connection("grader_feedback") msg.send() return grade_data