# email-utils **Repository Path**: the_machine/email_utils ## Basic Information - **Project Name**: email-utils - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-07 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # email-utils Utility function to handle email through python. ## Usage ### Read email ```python from email_utils import read_email email_config = { 'host': 'imap.mail.com', 'port': 993, 'username': 'youremail@mail.com', 'password': 'yourpassword' } eid = read_email.list_email_id( email_config=email_config, tag='Unseen' ) mail = read_email.fetch_mail( email_config=email_config, mail_id='508' ) mail.set_seen( email_config=email_config, mail_id='508' ) ``` ### Email object ```python from email_utils import raed_email # read email mail = read_email.fetch_email_object(mconfig=email_config, mid='508') # set flag mail.set_unseen() # save attachment att_fp = mail.save_attachment(dir='./', name='测试.txt', rename='test.txt')[0] ``` ### Send email, SSL connection only ```python from email_utils.send_email import send_email stmp_config = { 'host': '123.com.cn', 'port': 465, 'username': '123@123.com', 'password': '123' } email_content = { 'from': 'zhangxian@microcredchina.com', 'to': ['zhangxian@microcredchina.com', 'joker0414zx@163.com'], 'cc': None, 'subject': '测试发送邮件', 'text-content': '这是测试邮件', 'attachment': ['test.txt', 'test_att.xlx'] } send_email(email_content=email_content, stmp_config=stmp_config) ``` ## Reference https://www.runoob.com/python3/python3-smtp.html