如何一键删除工作邮箱里的邮件

女票抱怨公司邮箱又满了,一封封删除的好慢,删完了还是收不到邮件(大概是没有彻底删除)…

好,动手写个脚本一键删除邮件(动个屁手啊,百度一搜就出来了)

好,经测试修改兼容了python3,现在把代码分享出来

import poplib

def main():
    uugame = poplib.POP3('mail.xxxx.com',110)
    uugame.user('username@xxxx.com')
    uugame.pass_('password')
    totalNum, totalSize = uugame.stat()
    print("totalNum = "+str(totalNum)+";totalSize=" + str(totalSize))
    for i in range(totalNum):
        uugame.dele(i+1)
        print("index=" + str(i))
        print(uugame.stat())
    uugame.quit()
    print("finish")
if __name__ == '__main__':
    main()

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python自动化运维中,使用SMTplib库可以实现发送电子邮件的自动化功能。以下是一个基础的示例,展示如何通过SMTP协议发送一封带有附件的邮件: ```python import smtplib from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email import encoders import os # 邮件设置 sender_email = 'your_email@example.com' sender_password = 'your_email_password' # 如果是SMTP应用密码,请使用 receiver_email = 'recipient_email@example.com' subject = 'Automated Email from Python' body = 'This is an automated message sent using Python.' attachment_path = 'path_to_your_attachment' # 例如 'document.pdf' # 创建邮件对象 msg = MIMEMultipart() msg['From'] = sender_email msg['To'] = receiver_email msg['Subject'] = subject # 添加邮件正文 msg.attach(MIMEText(body, 'plain')) # 添加附件(如果有的话) with open(attachment_path, 'rb') as f: part = MIMEBase('application', 'octet-stream') part.set_payload(f.read()) encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="{}"'.format(os.path.basename(attachment_path))) msg.attach(part) # 连接SMTP服务器 smtp_server = 'smtp.example.com' # 根据你的邮箱提供商填写 smtp_port = 587 # 或者465 for SSL/TLS (default for Gmail is 465) try: with smtplib.SMTP(smtp_server, smtp_port) as server: server.starttls() # 如果需要加密连接,添加这行 server.login(sender_email, sender_password) server.sendmail(sender_email, receiver_email, msg.as_string()) print("Email sent successfully.") except Exception as e: print("Error sending email: ", str(e)) # 关闭连接 server.quit() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值