No attribute 'SMTP', error when trying to send email in Python

前端 未结 2 544
说谎
说谎 2020-12-20 11:12

I am trying to send an email in Python:

import smtplib


fromaddr = \'......................\'  
toaddrs  = \'......................\'  
msg = \'Spam email T         


        
2条回答
  •  独厮守ぢ
    2020-12-20 11:29

    Python already has an email module. Your script's name is email.py, which is preventing smtplib from importing the built-in email module.

    Rename your script to something other than email.py and the problem will go away.

提交回复
热议问题