如何循环这段代码,使其无限期重复。</ p>
如果我手动运行它只是想循环它,该程序就可以工作。
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()
答案 0 :(得分:0)
这应该有效。
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()