def sendMultiPart(smtp, gpg_context, sender, recipients, subject, text, attachments):
sent = <NUM_LIT:0><EOL>for to in recipients:<EOL><INDENT>if not to.startswith('<STR_LIT:<>'):<EOL><INDENT>uid = '<STR_LIT>' % to<EOL><DEDENT>else:<EOL><INDENT>uid = to<EOL><DEDENT>if not checkRecipient(gpg_context, uid):<EOL><INDENT>continue<EOL><DEDENT>msg = MIMEMultipart()<EOL>msg['<STR_LIT>'] = sender<EOL>msg['<STR_LIT>'] = to<EOL>msg['<STR_LIT>'] = subject<EOL>msg["<STR_LIT>"] = formatdate(localtime=True)<EOL>msg.preamble = u'<STR_LIT>'<EOL>attach = MIMEText(str(gpg_context.encrypt(text.encode('<STR_LIT:utf-8>'), uid, always_trust=True)))<EOL>attach.set_charset('<STR_LIT>')<EOL>msg.attach(attach)<EOL>for attachment in attachments:<EOL><INDENT>with open(attachment, '<STR_LIT:rb>') as fp:<EOL><INDENT>attach = MIMEBase('<STR_LIT>', '<STR_LIT>')<EOL>attach.set_payload(str(gpg_context.encrypt_file(fp, uid, always_trust=True)))<EOL><DEDENT>attach.add_header('<STR_LIT>', '<STR_LIT>', filename=basename('<STR_LIT>' % attachment))<EOL>msg.attach(attach)<EOL><DEDENT>smtp.begin()<EOL>smtp.sendmail(sender, to, msg.as_string())<EOL>smtp.quit()<EOL>sent += <NUM_LIT:1><EOL><DEDENT>return sent<EOL>
a helper method that composes and sends an email with attachments
    requires a pre-configured smtplib.SMTP instance