コード例 #1
0
 def content_disposition_headers(self):
     return (Headers([content_disposition("attachment", "ascii.filename")]),
             Headers([content_disposition("attachment", "файл.filename")]))
コード例 #2
0
ファイル: test_headers.py プロジェクト: eugene-eeo/mailthon
 def content_disposition_headers(self):
     return (Headers([content_disposition("attachment", "ascii.filename")]),
             Headers([content_disposition("attachment", "файл.filename")]))
コード例 #3
0
ファイル: enclosure.py プロジェクト: MaxwellGBrown/notebook
html_content = "<p>This is the <em>HTML</em> enclosure!</p>"
html = mailthon.enclosure.HTML(html_content, encoding='utf-8')

# file attachments. Attachment auto-populates the Content-Disposition header.
file_attachment = mailthon.enclosure.Attachment("./text.txt")

# binary attachments. Binary needs it's headers & MIMEtype populated
with open("sample.pdf", "rb") as attachment_file:  # rb for read binary
    binary_attachment_contents = attachment_file.read()

# mailthon.headers provides header formatting functions
from mailthon.headers import content_disposition
binary_attachment = mailthon.enclosure.Binary(
        content=binary_attachment_contents,
        mimetype='application/pdf',
        headers=[content_disposition('attachment', "sample.pdf")],
        )

# enclosures are added to a list to obstantiate Envelope
enclosures = [plaintext, html, file_attachment, binary_attachment]

headers = {
        "To": email,
        "From": email,
        "Subject": "2-Enclosure.py",
        }

envelope = mailthon.envelope.Envelope(headers, enclosures)

postman = mailthon.postman(smtp, auth=auth)
postman.send(envelope)