Skip to main content

A simple email sender utility

Project description

PyCourrier

PyCourrier is a Python package that simplifies composing and sending emails using SMTP. This package allows you to connect to an SMTP server, set up email content (including plain text, HTML, and attachments), specify recipients, and send emails seamlessly.

Features

  • Connect to SMTP servers (supports both SSL and TLS connections).
  • Compose emails with plaintext, HTML, and attachments.
  • Set multiple recipients for each email.
  • Easily send emails to all recipients with a single function call.

Installation

You can install PyCourrier using pip:

pip install PyCourrier

Usage

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

from PyCourrier import MailSender
from asyncio import run

async def main():
    # Create a MailSender instance within a context manager
    with MailSender('your_email@gmail.com', 'your_generated_app_password') as sender:

        # Set recipients
        recipients = ['recipient1@gmail.com', 'recipient2@gmail.com', 'recipient3@gmail.com']
        sender.set_recipients(recipients)

        # Set email message details
        in_subject='Hello from PyCourrier!'
        in_plaintext='This is the plain text content of the email.'
        in_htmltext='<p>This is the HTML content of the email.</p> (optional)'

        # Add attachments (optional)
        sender.add_attachment('path/to/attachment', 'filename')

        # set the message
        sender.set_message(in_plaintext=in_plaintext, in_subject=in_subject, in_htmltext=in_htmltext)
        await sender.send_all_async()


# Run the async main function
if __name__ == "__main__":
    run(main())

Parameters:

  • in_username: Your email address used for SMTP login.
  • in_password: Your generated app password for SMTP login.
  • in_server: Tuple containing the SMTP server address and port (default is 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.1.8.tar.gz (4.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.1.8-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyCourrier-0.1.8.tar.gz
  • Upload date:
  • Size: 4.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.1.8.tar.gz
Algorithm Hash digest
SHA256 2cc8f3545f0cb32201fc72789e71de4bfa1b1121d961ad21ff29c880a13e8574
MD5 62577bddc15807c8f8314aa0457b7a6f
BLAKE2b-256 19886c354ac327d334db78669db0670b62f4a5211ba10ab3e8e5cbdd28b92f50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyCourrier-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 082aecd242010d49d14f7d206eb43bde3d85c9022db519fc6d1f1479d6cd5214
MD5 fdf23e4061a6f9cb26d98f3cd1c7c036
BLAKE2b-256 4e0e9fd076f16c4f37b83a265c873a91c3869ae6fc6c2186427847c65f88ced6

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