Skip to main content

The classic email sending library for Python was expanded to include more useful features

Project description

PyMailers

The classic email sending library for Python, now with enhanced features like HTML templates and attachment support.

Installation

To install PyMailers, run the following command:

pip install pymailers

Features

Send emails with HTML content. Support for secure SMTP connections using starttls. Ability to send emails with attachments. Templating support using Jinja2 for dynamic email bodies. Optional logging for successful and failed email deliveries. Requirements Ensure you have the following Python modules installed: smtplib email os sys jinja2 (for templating) logging (for logging support)

You can install the required modules using pip:

pip install -r requirements.txt

Usage

PyMailers is simple to use yet powerful. Here's a quick example of sending an email with a plain text body. You can set display to False to suppress logs, or True to print logs after sending the email.

from pymailers.PyMailer import PyMailer

pymailer = PyMailer({
    'smtp_host': 'smtp.gmail.com',
    'smtp_port': 587,
    'email': 'your-email@gmail.com',
    'password': 'your-password',
    'to': 'recipient-email@gmail.com',
    'subject': 'Hello World',
    'body': '<p>Hi, I'm Rio</p>',
    'display': True
})

pymailer.send()

To send an email with attachments and using an HTML template:

pymailer = PyMailer({
    'smtp_host': 'smtp.gmail.com',
    'smtp_port': 587,
    'email': 'your-email@gmail.com',
    'password': 'your-password',
    'to': 'recipient-email@gmail.com',
    'subject': 'Greetings',
    'body': '', # Body will be generated by the template
    'display': True,
    'attachments': ['path/to/attachment1.pdf', 'path/to/image.jpg'],
    'template_path': 'path/to/template.html',
    'template_context': {'name': 'Rio'}
})

pymailer.send()

Make sure to replace the placeholders with your actual SMTP settings, email credentials, and file paths.

Logging All operations are logged into pymailer.log. This is helpful for auditing and debugging purposes.

Donate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymailers-2.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pymailers-2.0.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file pymailers-2.0.2.tar.gz.

File metadata

  • Download URL: pymailers-2.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for pymailers-2.0.2.tar.gz
Algorithm Hash digest
SHA256 d5b96de8f3d51486060b6463ee48a6931ee9230372acec63d6fef1359a2353bf
MD5 96b1ddc8bfe23b63b8502beb3bebbdb6
BLAKE2b-256 30519a2002f85c4570ce509403ec97ddab0c1dbbee6ed1c6dce8a6888677e0ca

See more details on using hashes here.

File details

Details for the file pymailers-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: pymailers-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for pymailers-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1db40efb93468ee1f02071fc291eb4ad96108869f7a734df3f16a7ce8f1cb3b6
MD5 a6f962019f4047056cb9091870a3124e
BLAKE2b-256 101b001e15d98e249bae1af48e431185f0c9060f8dcd8ad8eeaa30fb4cbe1ba1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page