创建电子邮件自动化/垃圾邮件系统我如何重复我的

2024-07-05 12:47:40 发布

您现在位置:Python中文网/ 问答频道 /正文

如何循环此代码,使其无限重复

如果我只是想循环,手动运行它,程序就可以运行

import smtplib 
gmailaddress = 'SENDER'
gmailpassword = 'PASSWORD'
mailto = 'RECEIVER'
msg = 'MESSAGE'
mailServer = smtplib.SMTP('smtp.gmail.com' , 587)
mailServer.starttls()
mailServer.login(gmailaddress , gmailpassword)
mailServer.sendmail(gmailaddress, mailto , msg)
print(" \n Sent!")
mailServer.quit()

Tags: 代码import程序messagemsgpassword手动smtp
1条回答
网友
1楼 · 发布于 2024-07-05 12:47:40

这应该行得通

import smtplib      
SPAM = 3
while (SPAM > 0):
    gmailaddress = 'SENDER'
    gmailpassword = 'PASSWORD'
    mailto = 'RECEIVER'
    msg = 'MESSAGE'
    mailServer = smtplib.SMTP('smtp.gmail.com' , 587)
    mailServer.starttls()
    mailServer.login(gmailaddress , gmailpassword)
    mailServer.sendmail(gmailaddress, mailto , msg)
    print(" \n Sent!")
    mailServer.quit()

相关问题 更多 >