python更加便捷发送邮件

参考链接:https://www.cnblogs.com/fnng/p/7967213.html

## pip install yagmail

import yagmail

# 链接邮箱服务器
yag = yagmail.SMTP(user="[email protected]", password="1234", host='smtp.126.com')

# 收件人
mail_to = ["[email protected]", "[email protected]"]

# 邮箱标题
subject = ['我是标题']

# 邮箱正文
contents = [
    '我是正文', 'You can find an audio file attached.', '/local/path/song.mp3'
]

# 邮箱附件
extra_file = ['/tmp/readme.md', '/tmp/test.txt']

# 发送邮件
yag.send(mail_to, subject, contents, extra_file)