AttributeError:'模块'对象没有属性'电子邮件'

时间:2014-09-06 05:58:49

标签: python

知道如何解决这个错误?我从这个link中获取了该程序,它对他们来说是正常的。

def send_text(phone_number, msg):
    fromaddr = "Craigslist Checker"
    toaddrs = phone_number + "@txt.att.net"
    msg = ("From: {0}\r\nTo: {1}\r\n\r\n{2}").format(fromaddr, toaddrs, msg)
    server = smtplib.SMTP('smtp.gmail.com:587')
    server.starttls()
    server.login(config.email['email'], config.email['password'])
    server.sendmail(fromaddr, toaddrs, msg)
    server.quit()

这是错误:

There are new results - sending text message to 2014-09-06 01:58:09
Traceback (most recent call last):
  File "t1.py", line 85, in <module>
    send_text(PHONE_NUMBER, message)
  File "t1.py", line 60, in send_text
    server.login(config.email['email'], config.email['password'])
AttributeError: 'module' object has no attribute 'email'

1 个答案:

答案 0 :(得分:1)

好的,你是一个python新手,对吧?设置应该是:

~$ wget https://github.com/gjreda/craigslist-checker/archive/master.zip
~$ cd craigslist-checker-master
~$ pip install -r requirements.txt
~$ echo "email={'username':'mail@gmail.com', 'password':'youpass'}" > config.py 
~$ python ./craigslist.py