SMTP电子邮件自动化功能

smtputilit的Python项目详细描述


SMTP_PyPi_包

  • SMTP帮助程序函数。只使用标准库。在

不带附件的电子邮件:发送不带附件的电子邮件。

defemail_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    """
示例调用
^{pr2}$

带附件的电子邮件:发送带附件的电子邮件。可以通过电子邮件发送任何数量/类型的附件。

defemail_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.         """
示例调用
fromsmtputilityimportemail_with_attachmentstest_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')
自动通知4错误报告
defnotify_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    """
示例调用
fromsmtputilityimportnotify_errorimportosdeffoo():raiseException('Error!')try:foo()exceptExceptionase:notify_error(f"{os.path.basename(__file__)}",e,"a@email.com",'email@domain.com','password')

通知\错误:自动电子邮件报告,用于异常捕获。

defdefault_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    """
示例调用
fromsmtputilityimportdefault_table_styleimportpandasaspdimportnumpyasnpdf=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>"""

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaSpringMVC控制器测试打印结果JSON字符串   若catch语句返回,那个么为什么它最终会阻塞呢?   java Grails中servletContext在哪里可用?   java Jhipster:如何为现有项目启用多种语言   java异常评估SpringEL表达式:“#fields.hasErrors('something')”   java如何验证SeleniumWebDriver中的文本颜色?   java在绘图时使用JPanel坐标   java如何初始化spring启动到project?   java如何通过JDBC的PreparedStatement将UUID数组插入HyperSQL数据库   java修改JVM以跨线程序列化文件访问   Javascript到Java正则表达式   使用Java运行时调用aspell程序时出现字符集问题。getRuntime()。执行官   执行RDP时的java Sukuli按钮识别   java如何使用okhttp更改connect请求的标头   java无法创建Maven Eclipse项目