Package: dm-easy-email
邮件封装简单的邮件推送功能，支持发送单个或多个收件/抄送人，支持附件上传项目结构easy-emailLISENCE.mdREADME.mdsetup.pysrc__init__.pyeasy_email.pytestsconfemail_conf.ymlcolumn_config.ymltemplatetemplate.html__init__.pyexample.pytable_example.pytest_class.py使用方法安装/更新pip install dm-easy-email               # 安装

pip install dm-easy-email --upgrade     # 更新配置文件模板模板1--邮件发送sender:
  xxx@example.com
passwd: 
  your_passwd
receiver:
  - aaa@example.com
  - bbb@example.com
subject:
  your_title
# Params below could be None
nickname:
  your_nickname
cc:
  ccc@example.com模板2--html列表配置参数- column_code: a
  column_name: a
  align: center
  unit: '%'
  width: 50px
- column_code: b
  column_name: b
  align: center
  unit: ''
  width: 150px
- column_code: c
  column_name: c
  align: center
  unit: ''
  width: 100px
- column_code: d
  column_name: d
  align: center
  unit: '%'
  width: 50px示例1(body_type='plain')from easy_email.easy_email import EasyEmail
from ruamel import yaml
import os


if __name__ == '__main__':
    print(os.getcwd())
    with open('conf/email.yml', 'r') as f:
        content = yaml.load(f, Loader=yaml.Loader)
    sender = content['sender']
    receiver = content['receiver']
    subject = content['subject']
    nickname = content['nickname']
    # file_path = 'conf/email.yml'
    passwd = content['passwd']
    cc = content['cc']
    email = EasyEmail(
        sender=sender, passwd=passwd,
        subject=subject, nickname=nickname, 
        receiver=receiver, cc=cc
        )
    body = 'Hello world'
    email.send(body)示例2(body_type='html')from easy_email.easy_email import EasyEmail
from ruamel import yaml
import pandas as pd
import string

if __name__ == '__main__':
    with open('conf/email_conf.yml', 'r') as f:
        content = yaml.load(f, Loader=yaml.Loader)

    with open('conf/column_config.yml', 'r') as f_config:
        column_config = yaml.load(f_config, Loader=yaml.Loader)
    
    df = pd.DataFrame(
        {'a': [i for i in range(10)],
        'b': ['a' for _ in range(10)],
        'c': ['hello' for _ in range(10)],
        'd': [i for i in range(10, 20)]}
        )
    df.to_csv('data/data.csv', index=None)
    sender = content['sender']
    receiver = content['receiver']
    subject = content['subject']
    nickname = content['nickname']
    file_path = 'data/data.csv'
    passwd = content['passwd']
    email = EasyEmail(
        sender=sender, passwd=passwd,
        subject=subject, nickname=nickname, 
        receiver=receiver,
        file_path=file_path
        )
    emo = {
        'col': ['a', 'd'], 
        'threshold': 16, 
        'is_upper': True
        }
    table_html = email.table_to_html(
                    df=df, 
                    column_config=column_config, 
                    sort={'var': ['a', 'd'], 'ascending': False},
                    row_limit=30, 
                    emo=emo
                    )
    template_html = open('template/template.html', encoding='utf8').read()
    body = string.Template(template_html).safe_substitute(
        {
            'task1': table_html
        }
    )
    email.send(body, 'html')多附件说明如需多附件，使用如下形式定义file_path参数即可。file_path = ["path1/file_name1", "path2/file_name2", ...]开发日志2022-2-17   # v0.1.0完成邮件推送功能开发与测试，并推至仓库完成打包并发布到pypi2022-2-28   # v0.1.1调整邮件发送类型，支持html2022-3-2    # v0.2.0新增dataframe转化html功能补充dataframe转化示例2022-3-4    # v0.2.1支持多附件上传2022-3-15   # v0.2.2调整参数类型，修复linux环境报错