This is a simple Python library for sending emails. It provides an easy way to configure and send emails from any Python code.
To install the imhotep_mail
library, you can use pip:
pip install imhotep-mail
Here's how you can use the library to send a simple email:
from imhotep_mail import send_mail
# SMTP server configuration
smtp_server = 'smtp.example.com'
smtp_port = 465
username = '[email protected]'
password = 'your-password'
#those are optional not required
user_ssl = False
user_tls = True
# Sending an email
to_email = '[email protected]'
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
If you need to send an email with attachments, you can specify them in the attachments
parameter:
from imhotep_mail import send_mail
# SMTP server configuration
smtp_server = 'smtp.example.com'
smtp_port = 465
username = '[email protected]'
password = 'your-password'
#those are optional not required
user_ssl = False
user_tls = True
# Sending an email with attachments
to_email = '[email protected]'
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
from imhotep_mail import send_mail
# SMTP server configuration for Gmail
smtp_server = 'smtp.gmail.com'
smtp_port = 465
username = '[email protected]' # 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 = '[email protected]'
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.
Contributions are welcome! You can submit issues and pull requests to help improve the library.
MIT License. See LICENSE for more information.