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.) (Check the config.py file for more details)
  • 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') as mail_sender:
        
        # Compose the email message
        mail_sender.set_message(
            in_subject='Hello from PyCourrier!',
            in_from='your_email@example.com',
            in_plaintext='This is a test email sent using PyCourrier',
            in_htmltext='<html><body><h1>This is a test email sent using PyCourrier.</h1></body></html>'
        )

        # Add attachments (Optional)
        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')

        # Adding an inline image (Optional)
        mail_sender.add_inline_image('path/to/image.jpg', 'image1', 'image.jpg')

        # 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. (Please note either in_plaintext or in_htmltext must be provided. If both are given, the email client will typically display the HTML version.)
  • 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.1.tar.gz (8.5 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.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyCourrier-0.2.1.tar.gz
  • Upload date:
  • Size: 8.5 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.1.tar.gz
Algorithm Hash digest
SHA256 e788f25d64441ba842c4dc1eef867303dc0c4493a45d0b9a76a0d68716bbc28a
MD5 34cd64021c2919e0be20e300e7ec0464
BLAKE2b-256 26d80c28686a11671a5afe3404c496b39b9ae78a8a76d6a87030d3e3623e113d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyCourrier-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23827d1c2f918c6d22969906050e3538e5a31af2c154023b064e125d3dab2945
MD5 204b9e5f602b6d9c0518903db29fc432
BLAKE2b-256 db5a9b9748148ddbb422842f68b950443f42d7772708c196e15c5da3106be3d9

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