Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
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
"""
from smtputility import email_without_attachment
test_message = """
<HTML>
<BODY>
Message Text
<br>
</BODY>
</HTML>
"""
email_without_attachment(test_message,'SMTP Testing','a@abc.com;b@abc.com;','c@abc.com','email@domain.com','password')
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.
"""
from smtputility import email_with_attachments
test_message = """
<HTML>
<BODY>
Message Text
<br>
</BODY>
</HTML>
"""
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')
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
"""
from smtputility import notify_error
import os
def foo():
raise Exception('Error!')
try:
foo()
except Exception as e:
notify_error(f"{os.path.basename(__file__)}", e, "a@email.com",'email@domain.com','password')
def default_table_style(df, index: False):
""" Apply a default clean table style to pandas df.to_html() for use in email strings.
:param index: Determines whether you want index displayed in the HTML. Defaults to False.
:type index: Boolean
:param df: Dataframe to apply the style to.
:type df: Pandas Dataframe
:return: HTML string for insertion in email.
:rtype: string
"""
from smtputility import default_table_style
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(15, 4)), columns=list('ABCD'))
test_message = f"""
<HTML>
<BODY>
{default_table_style(df,index=False)}
<br>
</BODY>
</HTML>
"""
FAQs
SMTP email automation functions
We found that smtputility demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.