'send confirmation e-mail'

def send_confirmation_emails(self, orderitems, is_order_type_business, csv_file, pdf_file, site_name, course_names):

    recipient_list = [(self.user.username, self.user.email, 'user')]
    if self.company_contact_email:
        recipient_list.append((self.company_contact_name, self.company_contact_email, 'company_contact'))
    joined_course_names = ''
    if self.recipient_email:
        recipient_list.append((self.recipient_name, self.recipient_email, 'email_recipient'))
        joined_course_names = ('    ' + ',    '.join(course_names))
    if (not is_order_type_business):
        subject = _('Order    Payment    Confirmation')
    else:
        subject = _('Confirmation    and    Registration    Codes    for    the    following    courses:    {course_name_list}').format(course_name_list=joined_course_names)
    dashboard_url = '{base_url}{dashboard}'.format(base_url=site_name, dashboard=reverse('dashboard'))
    try:
        from_address = configuration_helpers.get_value('email_from_address', settings.PAYMENT_SUPPORT_EMAIL)
        for recipient in recipient_list:
            message = render_to_string(('emails/business_order_confirmation_email.txt' if is_order_type_business else 'emails/order_confirmation_email.txt'), {'order': self, 'recipient_name': recipient[0], 'recipient_type': recipient[2], 'site_name': site_name, 'order_items': orderitems, 'course_names': ',    '.join(course_names), 'dashboard_url': dashboard_url, 'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1], 'order_placed_by': '{username}    ({email})'.format(username=self.user.username, email=self.user.email), 'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'], 'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME), 'payment_support_email': configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL), 'payment_email_signature': configuration_helpers.get_value('payment_email_signature')})
            email = EmailMessage(subject=subject, body=message, from_email=from_address, to=[recipient[1]])
            if is_order_type_business:
                email.content_subtype = 'html'
            if csv_file:
                email.attach(u'RegistrationCodesRedemptionUrls.csv', csv_file.getvalue(), 'text/csv')
            if (pdf_file is not None):
                email.attach(u'ReceiptOrder{}.pdf'.format(str(self.id)), pdf_file.getvalue(), 'application/pdf')
            else:
                file_buffer = StringIO.StringIO(_('pdf    download    unavailable    right    now,    please    contact    support.'))
                email.attach(u'pdf_not_available.txt', file_buffer.getvalue(), 'text/plain')
            email.send()
    except (smtplib.SMTPException, BotoServerError):
        log.error('Failed    sending    confirmation    e-mail    for    order    %d', self.id)
