Skip to main content

mailing utilty

Project description

PayoMail - Open Source Email Sending Utility ✉️

PayoMail is an open-source Python utility for sending emails with different email providers. It provides a flexible architecture supporting various email strategies and a convenient interface for configuring and sending emails.

Features 🚀

  • Modular Architecture: Choose from different email strategies like Gmail, IceWarp, etc.
  • Builder Pattern: Easily configure and customize emails using a builder pattern.
  • Template Support: Support for email templates with dynamic values.
  • File Attachment: Attach files from local paths or URLs.

Getting Started 🛠️

Follow these instructions to get a copy of the project up and running on your local machine.

Prerequisites 📋

  • Python 3.x

Installation 📦

  1. Clone the repository:

    git clone https://github.com/Roshangedam/payomail.git
    
  2. Navigate to the project directory:

    cd payomail
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Installation via pip 📦

PayoMail is available on PyPI, the Python Package Index. You can install it using pip:

pip install payomail

Usage 🖥️

# Your Python script

from payomail.core import mail, strategy
from payomail.template.template import HTMLTemplate


if __name__ == "__main__":
    # Create an email builder object
    roshan = (
        mail.EmailBuilder()
        .set_strategy(strategy.GmailStrategy())  
        .set_sender("sender@example.com")
        .set_password("SenderPassword")
        .build()
    )

    # Set maximum attachment size by default is 10mb
    roshan.set_max_attachment_size(10)

    # Set email subject
    roshan.set_subject("Mail from PayoMail")

    # Set email body from HTML template use {{mapping}} and mapp value of html with .set_value('mapping', 'some value')
    roshan.set_body_from_template(HTMLTemplate()
                                  .set_file_path('payomail/template/test.html')
                                  .set_value('greeting', 'Hello Bholya')
                                  .set_value('from', 'PayoMail Developer'))

    # Attach an image file single multiple with file path or url
    roshan.attach_file('payomail/images/icon.png')
    #roshan.attach_file('https://com.example/somefile.file')

    # Set recipient email address
    roshan.set_recipient("recipient@example.com")

    # Send the email
    response = roshan.send()
    
    # Displaying the response details
    print(f"Status: {response['status']}")
    print(f"From: {response['from']}")
    print(f"To: {response['to']}")
    print(f"Subject: {response['subject']}")
    print(f"Timestamp: {response['timestamp']}")

    # If there was a failure, print the error message
    if response['status'] == 'Failure':
        print(f"Error Message: {response['error_message']}")

Contributing 🤝

Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License 📄

This project is licensed under the License - see the LICENSE.md file for details.

Acknowledgments 🙌

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc.

This version of PayoMail supports email templates with dynamic values using the HTMLTemplate class. You can attach files from local paths or URLs using the attach_file method.

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

payomail-9.0.0.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file payomail-9.0.0.tar.gz.

File metadata

  • Download URL: payomail-9.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for payomail-9.0.0.tar.gz
Algorithm Hash digest
SHA256 1165d87f629acedef4bbd9e119f4178c85d83ad645e1c9a452bb83b45afc2692
MD5 129dcf9a43e9ced24c38d843322c4d2c
BLAKE2b-256 c4d08ec68e7e534ae9cd1eb90b6cb621a56456e58950a8de1509002eb943e0a4

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