SMTP email automation functions
Project description
SMTP_PyPi_Package
- SMTP Helper functions. Only uses Standard Library.
email_without_attachment: Send email without attachments.
def email_without_attachment(message: str, subject: str, to_list: str, cc_list: str, login: str, password: str):
"""
:param message: HTML String with Email message contained. See Examples/Email_Strings.py
:param subject: Subject String
:param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)
:param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)
:param login: Login email.
:param password: Password for O365
"""
Example Call
from mj.smtputility import email_without_attachment
test_message = """
<HTML>
<BODY>
Message Text
<br>
</BODY>
</HTML>
"""
smtp_msg_automation.email_without_attachment(test_message,'SMTP Testing','a@abc.com;b@abc.com;','c@abc.com','email@domain.com','password')
email_with_attachments: Send email with attachments. Can send any number/type of attachments in email.
def email_with_attachments(
message: str, subject: str, to_list: str, cc_list: str, login: str, password: str, *args
):
"""
:param login: Login email.
:param password: Password for O365.
:param message: HTML String with Email message contained. See Examples/Email_Body.html.
:param subject: Subject String
:param to_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)
:param cc_list: Semicolon separated list of email addresses. (ex - a@abc.com; b@abc.com; c@abc.com;)
:param *args: Paths to attachments.
"""
Example Call
from mj.smtputility import email_with_attachments
import smtp_msg_automation
test_message = """
<HTML>
<BODY>
Message Text
<br>
</BODY>
</HTML>
"""
smtp_msg_automation.email_with_attachments(test_message,'SMTP Testing','a@abc.com;b@abc.com;','c@abc.com','email@domain.com','password',
r'C:\Users\user\some_directory\test_1.txt')
notify_error: Automated email report for use in exception catch.
def notify_error(report_name, error_log, to_list: str,login: str, password: str):
"""
:param to_list: List of emails to receive notification.
:param report_name: Name of automated report.
:param error_log: Raised exception or other error to report.
:param login: Login email.
:param password: Password for O365
"""
Example Call
from mj.smtputility import notify_error
import os
def foo():
#do thing
try:
foo()
except Exception as e:
smtp_msg_automation.notify_error(f"{os.path.basename(__file__)}", e, "a@email.com",'email@domain.com','password')
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
smtputility-1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for smtputility-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d43f66baeaffe988354704343c873bfda7e670fc317e37f6ee46d6c2d0da60d |
|
MD5 | 044388c0f798f909f0765d23c3ab1475 |
|
BLAKE2b-256 | e111e97453ec16e08ca5bbaacdf76292c69c995c5a23c7f2a2f8445937b3bbec |