Skip to main content

A Python package for sending emails using various SMTP services

Project description

PyCourrier

PyCourrier is a Python package for sending emails using various SMTP services.

Features

  • Support for multiple email services (Gmail, Yahoo, Outlook, etc.)
  • Easy to use context manager for connecting and disconnecting from the SMTP server
  • Support for plain text and HTML email bodies
  • Attachment support
  • Asynchronous email sending

Installation

pip install PyCourrier

Usage

Here's a quick guide on how to use MailSender:

import asyncio
from PyCourrier import MailSender

async def main():
    # Initialize MailSender with your credentials and email service
    async with MailSender(in_username='your_email@example.com', 
                          in_password='your_app_password', 
                          in_service='gmail', 
                          use_SSL=True) as mail_sender:
        
        # Compose the email message
        mail_sender.set_message(
            in_subject='Test Email',
            in_from='your_email@example.com',
            in_plaintext='This is a test email with an attachment.',
            in_htmltext='<html><body><h1>This is a test email with an attachment.</h1></body></html>'
        )

        # Add attachments
        mail_sender.add_attachment(path='/path/to/your/file.txt', filename='file.txt')
        mail_sender.add_attachment(path='/path/to/another/file.pdf', filename='file.pdf')

        # Set recipients
        mail_sender.set_recipients(
            in_recipients=['recipient1@example.com', 'recipient2@example.com'],
            cc_recipients=['cc1@example.com'], # Optional (None by default)
            bcc_recipients=['bcc1@example.com'] # Optional (None by default)
        )

        # Send the email to all recipients
        await mail_sender.send_all_async()

# Run the main function
asyncio.run(main())

Parameters:

  • in_username: Your email address used for SMTP login.
  • in_password: Your generated app password for SMTP login.
  • in_server: Name of the email service provider (e.g., 'gmail', 'yahoo', 'outlook', or 'other'). Defaults to 'gmail'.
  • use_SSL: Boolean indicating whether to use SSL (True) or TLS (False, default) for the connection.

Methods:

  • set_message: Compose the email message with subject, plaintext, and HTML content.
  • add_attachment: Add an attachment to the email.
  • set_recipients: Set the list of email recipients.
  • connect: Connect to the SMTP server.
  • disconnect: Disconnect from the SMTP server.
  • send_all_async: Send the composed email to all recipients asynchronously.
  • send_email: Send the composed email to a specific recipient.

Contribution

Contributions to PyCourrier are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.

License

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

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

PyCourrier-0.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyCourrier-0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file PyCourrier-0.2.tar.gz.

File metadata

  • Download URL: PyCourrier-0.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for PyCourrier-0.2.tar.gz
Algorithm Hash digest
SHA256 0936638b3bd48b96d088b8eea91211de12d2b5094b68890952fd2b771e95aaff
MD5 c2f76705932807616e4ecd0125dd2fb3
BLAKE2b-256 2a27daef506128d0658f29dd5bf519365e20cc8f61bbd67e9470b0d9dda90aa7

See more details on using hashes here.

File details

Details for the file PyCourrier-0.2-py3-none-any.whl.

File metadata

  • Download URL: PyCourrier-0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for PyCourrier-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a672a2926024435f8396cd53235a6c76b301130c2b997841e7438c5ea0bc226f
MD5 a655329c0cc5bed606513a6439f52427
BLAKE2b-256 c85b1a9b8f0542b881ed70a7656ce983f81658d4d3ed9600224e45dc8b9e2ea1

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