• python爬虫之短信报警




    1
    import smtplib 2 import email.mime.multipart 3 import email.mime.text 4 5 def send_email(content=''): 6 """ 7 发送邮件 8 :param SMTP_host: smtp.163.com 9 :param from_addr: 发送地址:xxx@163.com 10 :param password: 密码: password 11 :param to_addrs: 发送给谁的邮箱: xxx@qq.com 12 :param subject: 邮件主题: test 13 :param content: 邮件内容: test 14 :return: None 15 """ 16 17 # 发送邮箱smtp服务器地址 18 SMTP_host = 'smtp.163.com' 19 # 发送邮箱账户 20 from_addr = '#######@163.com' 21 # 发送邮箱账户密码 22 password = '********' 23 # 收件人邮箱地址 24 to_addrs = '##########@139.com' 25 #右键主题 26 subject = '关于爬虫报警' 27 28 msg = email.mime.multipart.MIMEMultipart() 29 msg['from'] = from_addr 30 msg['to'] = to_addrs 31 msg['subject'] = subject 32 content = content+' 状态异常' 33 txt = email.mime.text.MIMEText(content) 34 msg.attach(txt) 35 36 smtp = smtplib.SMTP() 37 smtp.connect(SMTP_host, '25') 38 smtp.login(from_addr, password) 39 smtp.sendmail(from_addr, to_addrs, str(msg)) 40 smtp.quit() 41 42 send_email()
  • 相关阅读:
    idea打包jar部署Linux出现乱码
    HTML元素刷新方式
    Linux中Jar启动与停止
    Win10开机自启软件设置
    java后台数据传输到前端少一天,8小时
    mysql字符串提取数组排序
    maven 配置文件
    mac docker安装jupyter notebook镜像
    pycharm使用git
    github使用命令
  • 原文地址:https://www.cnblogs.com/lei0213/p/8459216.html
Copyright © 2020-2023  润新知