gpt4 book ai didi

python smtpd.SMTPServer : How to send reply message in process_message?

转载 作者:太空宇宙 更新时间:2023-11-04 02:16:39 29 4
gpt4 key购买 nike

在我的 smtpd.SMTPServer 实现中,我可以通过 process_message() 回调接收消息。如何将回复消息发送回发件人?

最佳答案

这是一个可以发送电子邮件的脚本,它适合我。不知道是不是你想要的,希望对你有帮助。

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText


fromaddr = "YOUR ADDRESS"
toaddr = "ADDRESS YOU WANT TO SEND TO"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SUBJECT OF THE MAIL"

body = "YOUR MESSAGE HERE"
msg.attach(MIMEText(body, 'plain'))

server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "YOUR PASSWORD")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()

关于 python smtpd.SMTPServer : How to send reply message in process_message?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52506823/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com