forked from spiritLHL/LotteryAutoScript_Station
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext2.py
More file actions
55 lines (48 loc) · 1.64 KB
/
text2.py
File metadata and controls
55 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from imbox import Imbox
from email.mime.text import MIMEText
import datetime, re, smtplib
with Imbox('imap.exmail.qq.com', '', '', ssl=True) as imbox:
# 获取全部邮件
inbox_message_after = imbox.messages(date__on=datetime.date.today())
for uid, message in inbox_message_after:
#print(message.subject) # 邮件主题
if message.body['plain'][0][:4] == "发生时间":
body = message.body['plain'][0]
body = body.replace(" ", '\n')
body = body.replace('{ "content": "', '\n').replace(' {"content":"', '\n')
body = body.replace(' "}', '\n').replace('" }', '\n')
id = re.findall(r"私信你(.*?)说", body)[0][1:-1]
else:
imbox.delete(uid)
#设置服务器所需信息
mail_host = 'smtp.exmail.qq.com'
mail_user = ''
#密码(部分邮箱为授权码)
mail_pass = ''
#邮件发送方邮箱地址
sender = ''
#邮件接受方邮箱地址,注意需要[]包裹,这意味着你可以写多个邮件地址群发
receivers = ['']
#设置email信息
#邮件内容设置
message = MIMEText(body,'plain','utf-8')
#邮件主题
message['Subject'] = 'title'
#发送方信息
message['From'] = sender
#接受方信息
message['To'] = receivers[0]
#登录并发送邮件
try:
smtpObj = smtplib.SMTP()
#连接到服务器
smtpObj.connect(mail_host,25)
#登录到服务器
smtpObj.login(mail_user,mail_pass)
#发送
smtpObj.sendmail(sender,receivers,message.as_string())
#退出
smtpObj.quit()
print('success')
except smtplib.SMTPException as e:
print('error',e) #打印错误