@inject(config=Config)<EOL>def send_email(sender, receivers, subject, text=None, html=None, charset='<STR_LIT:utf-8>', config=Injected):
smtp_config = config['<STR_LIT>']<EOL>if not isinstance(receivers, list) and not isinstance(receivers, tuple):<EOL><INDENT>receivers = [receivers]<EOL><DEDENT>msgs = []<EOL>if text is not None:<EOL><INDENT>msgs.append(MIMEText(text, '<STR_LIT>', charset))<EOL><DEDENT>if html is not None:<EOL><INDENT>msgs.append(MIMEText(html, '<STR_LIT:html>', charset))<EOL><DEDENT>if len(msgs) == <NUM_LIT:0>:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if len(msgs) == <NUM_LIT:1>:<EOL><INDENT>msg = msgs[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>msg = MIMEMultipart()<EOL>for m in msgs:<EOL><INDENT>msg.attach(m)<EOL><DEDENT><DEDENT>if sender is None:<EOL><INDENT>sender = smtp_config['<STR_LIT>']<EOL><DEDENT>msg['<STR_LIT>'] = subject<EOL>msg['<STR_LIT>'] = sender<EOL>msg['<STR_LIT>'] = "<STR_LIT:U+002CU+0020>".join(receivers)<EOL>smtp_server = smtplib.SMTP(**(smtp_config['<STR_LIT>']))<EOL>smtp_server.sendmail(sender, receivers, msg.as_string())<EOL>smtp_server.quit()<EOL>
Sends an email.

    :param sender: Sender as string or None for default got from config.
    :param receivers: String or array of recipients.
    :param subject: Subject.
    :param text: Plain text message.
    :param html: Html message.
    :param charset: Charset.
    :param config: Current configuration