'Converts the filename, content, mimetype triple into a MIME attachment
object.'

def _create_attachment(self, filename, content, mimetype=None):

    if (mimetype is None):
        (mimetype, _) = mimetypes.guess_type(filename)
        if (mimetype is None):
            mimetype = DEFAULT_ATTACHMENT_MIME_TYPE
    attachment = self._create_mime_attachment(content, mimetype)
    if filename:
        try:
            filename.encode(u'ascii')
        except UnicodeEncodeError:
            if (not six.PY3):
                filename = filename.encode(u'utf-8')
            filename = (u'utf-8', u'', filename)
        attachment.add_header(u'Content-Disposition', u'attachment', filename=filename)
    return attachment
