def _postNotification(smtpServer, smtpPort, requireTLS, sender, recipients, body):
    senderAddr = utils.splitMailAddress(sender)[1]
    recipientsAddr = [f[1] for f in utils.splitMailRecipients(recipients)]
    return Notifier._postMail(smtpServer, smtpPort, None, None, senderAddr,
                              recipientsAddr, StringIO(body),
                              requireTLS=requireTLS,
                              timeout=adminconsts.GLOBAL_MAIL_NOTIFY_TIMEOUT,
                              retries=adminconsts.GLOBAL_MAIL_NOTIFY_RETRIES)
    def __doPrepareMailPost(self, label, trigger, notifCtx, vars, docs):
        stateCtx = self._storeCtx.getStateContext()
        activCtx = stateCtx.newNotificationContext(NotificationTypeEnum.email,
                                                   label, ActivityStateEnum.started,
                                                   notifCtx, trigger)
        activStore = activCtx.store
        sender = self._notifierCtx.config.mailNotifySender
        senderAddr = utils.splitMailAddress(sender)[1]
        activStore.senderAddr = senderAddr
        recipients = notifCtx.recipients
        allRecipientsAddr = [f[1] for l in recipients.values() for f in l]
        activStore.recipientsAddr = allRecipientsAddr
        subject = vars.substitute(notifCtx.subjectTemplate)
        activStore.subject = subject

        toRecipientsFields = recipients.get(MailAddressTypeEnum.to, [])
        toRecipients = utils.joinMailRecipients(toRecipientsFields)
        ccRecipientsFields = recipients.get(MailAddressTypeEnum.cc, [])
        ccRecipients = utils.joinMailRecipients(ccRecipientsFields)

        body = vars.substitute(notifCtx.bodyTemplate)

        msg = MIMEMultipart()
        msg['Subject'] = subject
        msg['From'] = sender
        msg['To'] = toRecipients
        msg['cc'] = ccRecipients
        txt = MIMEText(body)
        msg.attach(txt)

        attachments = notifCtx.attachments
        if docs:
            for doc in docs:
                if doc.getType() in attachments:
                    mimeType = doc.getMimeType()
                    mainType, subType = mimeType.split('/', 1)
                    data = MIMEBase(mainType, subType)
                    data.set_payload(doc.asString())
                    email.Encoders.encode_base64(data)
                    data.add_header('Content-Disposition', 'attachment',
                                    filename=doc.label)
                    msg.attach(data)
        activStore.body = str(msg)

        return activCtx