Skip to main content

Posts is a Python library for send mail easily.

Installation

pip install posts

Examples

Here is the first one to send a mail in text:

from posts import Posts

mail = Posts('smtp-server', 'your-username', 'your-passwd')

with mail() as box:
        box.text('to_address', subject='Subject', content='Content')

Posts does not only support mail in text type, but also support html:

box.html('to_address', subject='Subject', content='Content')

Next, we can send a mail with attachments:

with mail() as box:
        box.attach({'example.jpg': './example.jpg})
        box.text('to_address', subject='Subject', content='Content')

Finally, we can send the Html mail with image. and in the example, we also use a alias for the sender:

with mail(alias='alias') as box:
        box.attach({
                        'example.jpg': './example.jpg'})
        box.html(
                recipient='to_address',
                subject='subject',
                content='<img src="cid:example.jpg">')

Maybe you need to send mail by ssl, don’t worry:

with mail(ssl=True) as box:
        box.text('to_address', subject='Subject', content='Content')

Chain Useage

Just try like this:

box.attach({'name1': '/path/to/file1',
                        'name2': '/path/to/file2'}).\
        attach({'name3': '/path/to/file3'}).\
        text('to_address', 'subject', 'content').\
        html(['to_address1', 'to_address2'], 'subject', 'content')

The text mail with attachment 1, 2, 3 will send to address, and then the html mail with attachment 1, 2, 3 will be sent ot address1, address2 together.

TODO

  • add alias for recipient.

  • add carbon copy.

  • add usage without with.

Release files for posts 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for posts 0.2.2
File Size Uploaded
posts-0.2.2.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for posts 0.2.2
File Interpreter ABI Platform
posts-0.2.2-py2-none-any.whl Python 2 none any Details

Total release size: 7.6 kB

Release files / posts-0.2.2.tar.gz

Download URL posts-0.2.2.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a36c26efb6d094a4dcb8161c20054ef6c8ea992281ef5e2b515ba16d8ead44d8
BLAKE2b-256 checksum
How to use checksums
721dbdb413aef1bb8a4848b5d4a14aa9ab8e48196196706782b8b3eb8bfe3d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / posts-0.2.2-py2-none-any.whl

Download URL posts-0.2.2-py2-none-any.whl
Size 4.6 kB
Tags Python 2
SHA-256 checksum
How to use checksums
8c3d56a74734d5cb0d3bf1b22db8a4a4c60e26daef7f9263e84394227325183a
BLAKE2b-256 checksum
How to use checksums
69b7986ca3e4d2255f664f1e84ef02d88bbae30791d12810e95d515ca4b3e325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

1 release file

0.1.7

2 release files

0.1.6

0.1.5

2 release files

0.1.4

2 release files

0.1.2

1 release file

0.1.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page