python AttributeError:模块“smtplib”没有属性“SMPT”

2024-09-30 14:32:01 发布

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

我是一个python初学者,我想从你那里得到一些帮助。 最近我写了一个关于电子邮件垃圾邮件(从配置文件中检索数据)的程序,它使用的是“smtp”模块,我不能很好地使用它,所以当我运行该程序时,它说:

enter any key to exit
enter 'spam' to spam an email
Enter: spam
Running..Running..Running..Running..Running..Running..Running..Traceback  (most recent call last):
File "C:\Users\Leon\Desktop\Progetti\Gdaze\Gdaze.py", line 61, in <module>
emailSetupAndGo(getData()[0], getData()[1], getData()[2], getData()[3], getData()[4], getData()[5])
File "C:\Users\Leon\Desktop\Progetti\Gdaze\Gdaze.py", line 46, in emailSetupAndGo
server = smtplib.SMPT('smtp.gmail.com:587')
AttributeError: module 'smtplib' has no attribute 'SMPT'

在看到这个错误之后,我搜索了它,在stackoverflow上找到了一个解决方案,但它只适用于命名该文件的人电子邮件.py. 这是源代码(我还认为我用.split('')删除空格时出错),所以您可以告诉我错误是什么:

^{pr2}$

这是配置文件:

username = <yourgmail's>
password = <yourgmail's>
number of emails to spam = <int> 
fromemail = <youremail>
toemail = <emailtospam>
message = <msg>

Tags: topy程序电子邮件配置文件spamusersrunning