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

时间:2019-02-12 01:07:23

标签: python gmail

如何循环这段代码,使其无限期重复。<​​/ 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()

1 个答案:

答案 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()