使用Yagmail 发送邮件

使用Yagmail 的时候有要注意:如果接收者有多个或者是附件有多个时对应的变量要使用数组来传值
`import yagmail

class SendEamils(object):
"""发送邮件"""

@staticmethod
def send_report(subjects, cons, files):
    # 初始化服务器等信息
    smtp_server = "sit_test@xx.com"
    from_user = "sit_test@xx.com"
    from_pass_word ="123456"
    to_user = ["qq@xx.com","qq1@xx.com"]

    # 连接邮箱Server
    yag = yagmail.SMTP(user=from_user, password=from_pass_word, host=smtp_server)
    # 发送邮件
    yag.send(to_user, subject=subjects, contents=cons, attachments=files)
    yag.close()

`

posted on 2021-03-14 10:59  T相信未来  阅读(150)  评论(0)    收藏  举报

导航