邮件自动化——解放人工监控的双手,用于机器报错提醒

方案1

import yagmail
# 登录SMTP服务器
# user - 邮箱账号
# password - 邮箱登录授权码
# host - 邮箱SMTP服务器地址
yag = yagmail.SMTP(user = "user", password='password', host = 'smtp.yeah.net')

# 编辑邮件内容
contents = [
    'Hello, i am sent by yagmail!',
    'Here is a test mail!',
 #   yagmail.inline('E://avator.png'),#内嵌图片
  #  'E://avator.png'  #以附件形式发送
    ]

# 发送邮件
# to - 收信邮箱
# subject - 邮件主题
# contents - 邮件内容
yag.send(to = ['@163.com'], subject = 'SendHelloTest', contents = contents)
import yagmail
# 登录SMTP服务器
# user - 邮箱账号
# password - 邮箱登录授权码
# host - 邮箱SMTP服务器地址
yag = yagmail.SMTP(user = '@126.com', password = '', host = 'smtp.126.com')

# 编辑邮件内容
con = [
    'auto',
    'end'
    ]
at = [
    'C:\\Users\Admin\\Documents\\vscode\\水产污染\\2006年污染.csv',
     ]
yag.send(to = ['@163.com'], subject = 'SendHelloTest', contents = con,attachments=at)

方案2

https://zhuanlan.zhihu.com/p/89868804

猜你喜欢

转载自blog.csdn.net/qq_42830971/article/details/112429255