Pynnacle
A utility class to simplify sending emails.
Pynnacle provides a wrapper to mimetypes, smtplib and email.message libraries to provide a simplified facade interface to make sending emails as simple as possible. It abstracts away all the low level details and when imported into other modules provides a clean, clutter-free interface.
Installation
OS X & Linux:
pip3 install pynnacle
Windows:
pip install pynnacle
Usage example
Firstly import the module
from pynnacle.pynnacle import SendEmail
Pynnacle stores the configuration of email servers in an 'ini' configuration file. If a service is already configured then the main class can be instantiated with only 3 arguments e.g.:
mailer = SendEmail(
service="gmail",
user_id="jsmith",
user_pass="P@zzw0rd1",
)
If the service has not been configured, simply pass "custom" as the service and pass the other smtp arguments to the initializer e.g.:
mailer = SendEmail(
service="custom",
user_id="jsmith",
user_pass="P@zzw0rd1",
smtp_server="smtp.abc.com",
smtp_port=25,
smtp_authentication="yes",
smtp_encryption="yes",
)
Then simply send the email
mailer.message_send(
subject="Hi There",
sender="sender@abc.com",
recipient="recipient@xyz.com",
body="This is where the text of the email body goes",
)
cc, bcc and attachments arguments can also be used, supplied as lists
mailer.message_send(
subject="Hi There",
sender="sender@abc.com",
recipient="recipient@xyz.com",
body="This is where the text of the email body goes",
cc=["person1@def.com", "person2@ghi.com"],
bcc=["person3@jkl.com", "person4@mno.com"],
attachments=["path_to_file1", "path_to_file2"]
)
Further simplifications
Storing and Reusing SMTP
Additional setting can be saved in the "ini" file as and when you like.
e.g.config.ini
[gmail]
smtp_server = smtp.gmail.com
smtp_port = 587
smtp_authentication = yes
smtp_encryption = yes
pop3_server = pop.gmail.com
pop3_port = 995
pop3_authentication = yes
pop3_encryption = yes
Storing credentials
To avoid hard-coding any credentials I use the Python keyring library
service = "gmail"
user_id = keyring.get_password(service, "service_id")
user_pass = keyring.get_password(service, "service_password")
For more examples and usage, please refer to the Wiki.
A Note on gmail authentication
As of 30/05/2022 Google will no longer support the use of third-party apps or devices that only ask for your username and password. The "Less secure app access" setting has now been turned off. The application now has to be assigned a 16 byte code which can be configured from your account as follows:
- 1 Log onto your account: https://myaccount.google.com
- 2 Goto security
- 3 Enable 2-step verification
- 4 click "App password" to generate the key
Then simply use this along with the account email address to authenticate
Documentation
Meta
Stephen R A King : sking.github@gmail.com
Distributed under the MIT license. See for more information.
Created with Cookiecutter template: pydough version 1.2.1
Metadata
Release files for pynnacle 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pynnacle-1.1.2.tar.gz | 13.6 kB | Without provenance | Details for pynnacle-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pynnacle-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for pynnacle-1.1.2-py3-none-any.whl |
Total release size: 22.6 kB
Release files / pynnacle-1.1.2.tar.gz
| Download URL | pynnacle-1.1.2.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c0ee089d5483bcaa72fcc2e7dbf6dfacda364aaaff4795488d03f8e392904fb
|
|
BLAKE2b-256 checksum How to use checksums |
4dedc4a89bb55998dc4fcbb4ff98bf1cb541a09733690b208aa4233f009ec159
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.10
|
Release files / pynnacle-1.1.2-py3-none-any.whl
| Download URL | pynnacle-1.1.2-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb715acac6f7c8d994dd170ce9343709a07b46dbe228cb6db74090e298db026e
|
|
BLAKE2b-256 checksum How to use checksums |
26fcdc350ac1898b48a505078216396a3638133b99499d2e1b1a603ef76c2c98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.10
|
Security for pynnacle 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.