def send_mail(subject, text_content, from_email, to, html_content=None, attachments=[], cc=[], bcc=[]):
msg = EmailMultiAlternatives(subject, text_content, from_email, to, cc=cc, bcc=bcc)<EOL>if html_content:<EOL><INDENT>msg.attach_alternative(html_content, "<STR_LIT>")<EOL><DEDENT>if attachments:<EOL><INDENT>for att in attachments:<EOL><INDENT>if att:<EOL><INDENT>mimetype = mimetypes.guess_type(att)[<NUM_LIT:0>]<EOL>if str(mimetype) in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>with open(att, '<STR_LIT:r>') as f:<EOL><INDENT>email_embed_image(msg, att, f.read())<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>print(e)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>msg.attach_file(att)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return msg.send()<EOL>
This function sends mail using EmailMultiAlternatives and attachs all attachments
passed as parameters