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.pyfile 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyCourrier-0.2.2.tar.gz.
File metadata
- Download URL: PyCourrier-0.2.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbe9e999e906567cd4e9a1296e8cada6d0b732de36c84320e7f9cc0954065d67
|
|
| MD5 |
5eb1ed5040007c698b1595aae813cced
|
|
| BLAKE2b-256 |
4083bedfd74f0d4e3b591593cd9d758505f4972844c22fcddd3c15945a498e8e
|
File details
Details for the file PyCourrier-0.2.2-py3-none-any.whl.
File metadata
- Download URL: PyCourrier-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e3584ae5dde4222c6f6a7b41d72042f412f291495b826bf4db5785525cfb5df
|
|
| MD5 |
5aba0e80a6805c5a1b80d6cf226164d1
|
|
| BLAKE2b-256 |
1892b0079b6e5420f46f9cb6dcd5f48c76f6af7ab2b21a0dc6acc4dcb677e6ce
|