README
Code Quality
Description
concrete-mailer is a python package for sending rich e-mails.
- It automatically embeds the linked image in email inline attachments.
- It avoids emails to end up in SPAM (applying best practices, with no guarantee)
- It automatically converts rich e-mails in plain-text format for receivers who have not enabled HTML format
- It allows sending e-mails with attachements
- It inlines CSS (no header in HTML e-mails)
⚠ warning It requires an SMTP server.
Setup the environment
pip install concrete-mailer
User Guide
concrete-mailer can be used in two ways:
1- Email Client (client.py)
from concrete_mailer.client import EmailSenderClient
import os
#: Define the smtp connexion variables in:
#: SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_HOST_USER, SMTP_HOST_PASSWORD
client = EmailSenderClient(
email_host=os.getenv('SMTP_HOST_NAME'), #: smtp hostname
email_port=os.getenv('SMTP_HOST_PORT'), #: smtp host port
email_host_user=os.getenv('SMTP_HOST_USER'), #: smtp host username
email_host_password=os.getenv('SMTP_HOST_PASSWORD'), #: smtp host password
use_tls=os.getenv('SMTP_USE_TLS') == '1', #: smtp use tls
)
for name, email in (('John', 'john@mail.ext'), ('Jane', 'jane@mail.ext')):
client.send(
context={'name': name},
template='''
<h1>Concrete Mailer</h1>
<p>Hello {{name}}. Welcome to README</p>
<img src="/path/to/image1.jpg">
''',
title='README',
dests=[email, 'cc@netsach.org'],
sender_name='Netsach',
sender_email='sender@netsach.org',
reply_to='contact@netsach.org',
attachments=['/path/to/file.zip', '/path/to/image2.png'],
)
send method returns:
Trueif the email is successfully sent.Falseif a problem has occured.
2- Email preparers (preparer.py)
from concrete_mailer.preparers import prepare_email
import os
#: Define the smtp connexion variables in:
#: SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_HOST_USER, SMTP_HOST_PASSWORD
for name, email in (('John', 'john@mail.ext'), ('Jane', 'jane@mail.ext')):
email = prepare_email(
context={'name': name},
html='''
<h1>Concrete Mailer</h1>
<p>Hello {{name}}. Welcome to README</p>
<img src="/path/to/image1.jpg">
''',
title='README',
css='', #: extra css
sender='Netsach <sender@netsach.org>',
reply_to='contact@netsach.org',
recipients=[email, 'cc@netsach.org'],
attachments=['/path/to/file.zip', '/path/to/image2.png'],
email_host=os.getenv('SMTP_HOST_NAME'), #: smtp hostname
email_port=os.getenv('SMTP_HOST_PORT'), #: smtp host port
email_host_user=os.getenv('SMTP_HOST_USER'), #: smtp host username
email_host_password=os.getenv('SMTP_HOST_PASSWORD'), #: smtp host password
use_tls=os.getenv('SMTP_USE_TLS') == '1', #: smtp use tls
)
email.send()
send method returns:
Trueif the email is successfully sent.Falseif a problem has occured.
Debug
Python standard package includes a smtpd module.
According to the official documentation
This module offers several classes to implement SMTP (email) servers.
One of thoses classes is DebuggingServer.
Create a new debugging server. Arguments are as per SMTPServer. Messages will be discarded, and printed on stdout.
If you want to test your emails, open a new console and invoke the following command:
python3 -m smtpd -n -c DebuggingServer localhost:1025
and configure your environment :
SMTP_HOST_NAME='localhost'
SMTP_HOST_PORT='1025'
SMTP_HOST_USER=''
SMTP_HOST_PASSWORD=''
SMTP_USE_TLS=''
The email body will be displayed in console instead of being sent to destinations. Only local stmp connection will be established (dry-run)
Metadata
Release files for concrete-mailer 2.19.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 |
|---|---|---|---|---|
| concrete-mailer-2.19.1.tar.gz | 18.1 kB | Without provenance | Details for concrete-mailer-2.19.1.tar.gz |
Release files / concrete-mailer-2.19.1.tar.gz
| Download URL | concrete-mailer-2.19.1.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
670e6523f52ce35eedfbb9a1f05302a4ca9b4994c1a8ef2ffcfcbce041f982be
|
|
BLAKE2b-256 checksum How to use checksums |
495e9d5bddbdc016ec6de2616142bd30c2cc66179980e5eccaeceaf3df376004
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.17
|
Security for concrete-mailer 2.19.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.