Skip to main content

Simple library to write python emails

Project description

Mailer Module

Overview

The Mailer module is a configurable Python class that handles email functionalities across an application. It provides robust features for sending emails with HTML templates, attachments, and scheduling, as well as reading emails with advanced filtering capabilities.

Features

  • Send emails with HTML templates
  • Dynamic HTML template rendering
  • Attachment support
  • CC and BCC email support
  • Email validation
  • Email scheduling
  • Email reading with filtering
  • IMAP and SMTP support

Installation

Dependencies

  • Python 3.7+
  • Required libraries:
    • Pillow (PIL)
    • beautifulsoup4

Install dependencies using pip:

pip install Pillow beautifulsoup4

Usage

Initializing the Mailer

from emailfly import Emailer

mailer = Mailer(
    sender_email="your_email@example.com",
    password="your_password",
    sender_name="Your Name",
    port=587,
    smtp_server="smtp.gmail.com"
)

Sending an Email

result = mailer.send_email(
    subject="Welcome",
    html_template="app/templates/welcome",
    recipients=["recipient@example.com"],
    data={"name": "John Doe"},
    cc_email=["cc@example.com"],
    bcc_email=["bcc@example.com"]
)

Scheduling an Email

result = mailer.schedule_email(
    subject="Delayed Notification",
    html_template="app/templates/notification",
    recipients=["recipient@example.com"],
    delay_seconds=3600  # Send after 1 hour
)

Reading Emails

emails = mailer.read_emails(
    username="your_email@example.com",
    password="your_password",
    folder="INBOX",
    limit=5,
    filter_criteria={
        "from": "sender@example.com",
        "subject": "Important"
    },
    mark_as_read=True
)

Important Notes

  • Use app-specific passwords for Gmail
  • Ensure HTML templates are properly formatted
  • Handle exceptions when sending or reading emails

Security

  • Never hardcode sensitive information like passwords
  • Use environment variables or secure credential management

Limitations

  • Requires internet connectivity
  • Email sending/reading depends on SMTP/IMAP server availability

Contributing

Contributions are welcome! Please submit pull requests or open issues on the project repository.

License

[Add your project's license information]

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

emailfly-1.0.0.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file emailfly-1.0.0.tar.gz.

File metadata

  • Download URL: emailfly-1.0.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for emailfly-1.0.0.tar.gz
Algorithm Hash digest
SHA256 585d350c8e7e8a7c7153915a99ce9d58587a04db0c51eeb605210d75b2b3f942
MD5 1d5155c5e306fc93958142687bc65f73
BLAKE2b-256 e4360a1aac469a6f6643dc845474f4a973f74efdf0ccad213ce2766a1c197e88

See more details on using hashes here.

Supported by

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