def send_confirmation_email(subject, buyer_name, buyer_email, order, template_name, message=None): service = get_service_instance() html_content = get_mail_content(subject, '', template_name=template_name, extra_context={ 'buyer_name': buyer_name, 'order': order, 'message': message }) sender = '%s <no-reply@%s>' % (service.project_name, service.domain) msg = EmailMessage(subject, html_content, sender, [buyer_email]) bcc = [service.member.email, service.config.contact_email] msg.bcc = list(set(bcc)) msg.content_subtype = "html" Thread(target=lambda m: m.send(), args=(msg, )).start()
last_modified_date__contains=day_diff, state=lgc_models.INVOICE_STATE_DONE, type=lgc_models.INVOICE) for i in invoices.all(): response = http.HttpResponse(content_type='application/pdf') filename = 'FA' + str(i.number).zfill(5) + '.pdf' pdf = subprocess.Popen( os.path.join(settings.BASE_DIR, 'php_pdf/print.php') + ' ' + str(i.id), shell=True, stdout=subprocess.PIPE).stdout.read() email = EmailMessage() if i.language == 'FR': email.subject = r.subject_fr body = r.template_fr else: email.subject = r.subject_en body = r.template_en email.body = string_template(body).substitute( INVOICE_DATE=i.invoice_date, FIRST_NAME=i.po_first_name, LAST_NAME=i.po_last_name) email.from_email = settings.INVOICE_REMINDER_EMAIL email.to = [i.po_email] email.bcc = [settings.INVOICE_REMINDER_EMAIL] email.attach(filename=filename, mimetype='application/pdf', content=pdf) email.send()