yagmail 發送郵件

python更加便捷發送郵件

參考連接:https://www.cnblogs.com/fnng/p/7967213.htmlhtml

## pip install yagmail

import yagmail

# 連接郵箱服務器
yag = yagmail.SMTP(user="user@126.com", password="1234", host='smtp.126.com')

# 收件人
mail_to = ["ccccc@qq.com", "ddddd@qq.com"]

# 郵箱標題
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)
相關文章
相關標籤/搜索