littlefish/lfsmailer.py
def send_mail(recipient_list, subject, body, html=False, from_address=None):
    """
    :param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
    :param subject: The subject
    :param body: The email body
    :param html: Is this a html email? Defaults to False
    :param from_address: From email address or name and address i.e. 'Test System <errors@test.com>
    :return:
    """
    if not _configured:
        raise Exception('LFS Mailer hasn\'t been configured')

    if from_address is None:
        from_address = default_email_from
    
    mime_type = 'html' if html else 'plain'
    log.debug('Sending {} mail to {}: {}'.format(mime_type, ', '.join(recipient_list), subject))
    if dump_email_body:
        log.info(body)

    s = smtplib.SMTP(host, port)

    if use_tls:
        s.ehlo()
        s.starttls()
        s.ehlo()
    
    if username:
        s.login(username, password)

    if email_to_override:
        subject = '[to %s] %s' % (', '.join(recipient_list), subject)
        recipient_list = [email_to_override]
        log.info('Using email override: %s' % ', '.join(recipient_list))

    msg = MIMEText(body, mime_type, 'utf-8')
    msg['To'] = ', '.join(recipient_list)
    msg['Subject'] = subject
    msg['From'] = from_address
    msg['Date'] = email.utils.formatdate()

    s.sendmail(from_address, recipient_list, msg.as_string())
    s.quit()
def send_mail(recipient_list, subject, body, html=False, from_address=None):
    """
    :param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
    :param subject: The subject
    :param body: The email body
    :param html: Is this a html email? Defaults to False
    :param from_address: From email address or name and address i.e. 'Test System <errors@test.com>
    :return:
    """
    if not _configured:
        raise Exception('LFS Mailer hasn\'t been configured')

    if from_address is None:
        from_address = default_email_from
    
    mime_type = 'html' if html else 'plain'
    log.debug('Sending {} mail to {}: {}'.format(mime_type, ', '.join(recipient_list), subject))
    if dump_email_body:
        log.info(body)

    s = smtplib.SMTP(host, port)

    if use_tls:
        s.ehlo()
        s.starttls()
        s.ehlo()
    
    if username:
        s.login(username, password)

    if email_to_override:
        subject = '[to %s] %s' % (', '.join(recipient_list), subject)
        recipient_list = [email_to_override]
        log.info('Using email override: %s' % ', '.join(recipient_list))

    msg = MIMEText(body, mime_type, 'utf-8')
    msg['To'] = ', '.join(recipient_list)
    msg['Subject'] = subject
    msg['From'] = from_address
    msg['Date'] = email.utils.formatdate()

    s.sendmail(from_address, recipient_list, msg.as_string())
    s.quit()
:param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
    :param subject: The subject
    :param body: The email body
    :param html: Is this a html email? Defaults to False
    :param from_address: From email address or name and address i.e. 'Test System <errors@test.com>
    :return: