A python library to send mails easily
Project description
Imhotep Mail
This is a simple Python library for sending emails. It provides an easy way to configure and send emails from any Python code.
Installation
To install the imhotep_mail
library, you can use pip:
pip install imhotep-mail
Usage
Example 1: Sending a Simple Email
Here's how you can use the library to send a simple email:
from imhotep_mail import mail_config, send_mail
# SMTP server configuration
smtp_server = 'smtp.example.com'
smtp_port = 465
username = 'your-email@example.com'
password = 'your-password'
#those are optional not required
user_ssl = False
user_tls = True
# Sending an email
to_email = 'recipient@example.com'
subject = 'Hello from Imhotep Mail!'
body = 'This is a test email sent using the Imhotep Mail library.'
is_html = False
success, error = send_mail(smtp_server, smtp_port, username, password, to_email, subject, body, is_html)
if error:
#do somthing
Example 2: Sending an Email with Attachments
If you need to send an email with attachments, you can specify them in the attachments
parameter:
from imhotep_mail import mail_config, send_mail
# SMTP server configuration
smtp_server = 'smtp.example.com'
smtp_port = 465
username = 'your-email@example.com'
password = 'your-password'
#those are optional not required
user_ssl = False
user_tls = True
# Sending an email with attachments
to_email = 'recipient@example.com'
subject = 'Hello from Imhotep Mail!'
body = 'This is a test email sent using the Imhotep Mail library.'
is_html = False
attachments = ['path/to/attachment1.pdf', 'path/to/attachment2.jpg']
success, error = send_mail(smtp_server, smtp_port, username, password, to_email, subject, body, is_html, attachments, user_tls, user_ssl)
if error:
#do somthing
Gmail Example
from imhotep_mail import mail_config, send_mail
# SMTP server configuration for Gmail
smtp_server = 'smtp.gmail.com'
smtp_port = 465
username = 'your-email@gmail.com' # Replace with your Gmail email address
password = 'your-app-password' # Replace with the app password generated from Google account settings
# Sending an email to a Gmail address
to_email = 'recipient@example.com'
subject = 'Hello from Imhotep Mail!'
body = 'This is a test email sent using the Imhotep Mail library.'
is_html = False
success, error = send_mail(smtp_server, smtp_port, username, password, to_email, subject, body, is_html)
if error:
#do somthing
In this example, you need to replace 'your-app-password'
with the actual app password generated from your Gmail account settings. The app password
is different from your regular password and allows access to only your Gmail account, so it's more secure than your regular password.
For more information on how to generate an app password for Google, you can refer to Google's documentation.
Contributing
Contributions are welcome! You can submit issues and pull requests to help improve the library.
License
MIT License. See LICENSE for more information.
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
Hashes for imhotep_mail-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ca6a0368f3ad18c0412c5cd45348d10448af8b6c85aa68be157016aa9867fee |
|
MD5 | d9bafae461180a149683d6d0d866b4a5 |
|
BLAKE2b-256 | 4ec247c540a5f7a4213ddd84c43ccf3995ec783688faa254d784ee1cbf66b0fa |