pymailclient
er is a python wrapper that can be used to send beautiful email in any python base application. it allow developers to pass in their html template and the wrapper will render it and send the beautiful template out the reciepient. It can also be used to send attachements with email sent to reciepient.
DOCUMENTATION
INSTALLATION
We have to install the library into our virtual environment and we can do that by using the below command.
pip install pymailclient
or
pip3 install pymailclient
USAGE
After Installation, we need to create a directory in our project and name it "template" and then create another directory called "email" which will house all our html email files. ie
project directory -> template -> email -> email html files
THEN
import all the functions
from email_client.pymail import clients, Email
Initiate the class
send = Email()
Supply all the SMTP credentials that will be used to send the email out.
credential = clients(
email_host='smtp.gmail.com',
email_port='587',
email_user='email',
email_pass='password',
email_protocol='TLS',
email_sender='sender'
)
Declare your HTML Template
html = 'templatename.html'
Load the HTML Template in the function and pass in the data you want to pass to the html template from python as a dictionary.
template_data = send.load_template(html, {'name':'samson', 'amount':'1000'})
In the html template, you can now get the value of the data passed from python by using the the jinja2 pattern. ie
{{name}} {{amount}}
<!DOCTYPE html">
<html xmlns="http://www.w3.org/1999/xhtml">
<h1>Hi {{name}},</h1>
<strong>Amount:</strong> {{amount}}
</html>
Then we can now call the function to send the email by using the below function.
SEND WITHOUT ATTACHED FILE
send.sendEmail(
credential,
template_data,
receiver_email='reciever@gmail.com',
subject="Python Test",
bcc='test@gmail.com, test2@gmail.com'
)
SEND EMAIL WITH ATTACHED FILE
send.sendEmailWithFile(
credential,
template_data,
subject="Python Test",
receiver_email='reciever@gmail.com',
pathToFile='path to file/Report.pdf',
docName='test',
bcc='test@gmail.com, test2@gmail.com'
)
FULL USAGE
from email_client.pymail import clients, Email
send = Email()
credential = clients(
email_host='smtp.gmail.com',
email_port='587',
email_user='email',
email_pass='password',
email_protocol='TLS',
email_sender='sender'
)
html = 'templatename.html'
template_data = send.load_template(html, {'name':'samson', 'amount':'1000'})
//Send without files/attachement //
send.sendEmail(
credential,
template_data,
receiver_email='reciever@gmail.com',
subject="Python Test",
bcc='test@gmail.com, test2@gmail.com'
)
// Send with attachement //
send.sendEmailWithFile(
credential,
template_data,
subject="Python Test",
receiver_email='reciever@gmail.com',
pathToFile='path to file/Report.pdf',
docName='test',
bcc='test@gmail.com, test2@gmail.com'
)
NOTE
If you dont want to use bcc, kindly set it to None. ie bcc=None. Also the email protocol must be either SSL or TLS depending the protocol you are using.
Metadata
Release files for pymailclient 1.0.1
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 |
|---|---|---|---|---|
| pymailclient-1.0.1.tar.gz | 16.2 kB | Without provenance | Details for pymailclient-1.0.1.tar.gz |
Release files / pymailclient-1.0.1.tar.gz
| Download URL | pymailclient-1.0.1.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b69205d4286f99e6fdb92ca94bc1ec590c784f5a28fb163bb46cf660ba3799aa
|
|
BLAKE2b-256 checksum How to use checksums |
7029c24b18687d24682b64e04480d1901b5617fe5e8120a89acc5a14f66c4a10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for pymailclient 1.0.1
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.