所以我有这个Python发送电子邮件文件,它将电子邮件(文件中的文本)发送给代码中指定的收件人:
import smtplib
from email.mime.text import MIMEText
msgContent = open(Sourcefilelocation, "rb")
msg = MIMEText(spam.read())
msgContent.close()
msg['Subject'] = SUBJECT
msg['From'] = FROM_CLIENT_EMAIL
msg['To'] = TO_CLIENT_EMAIL
#THE ERROR BELOW
s = smtplib.SMTP('localhost')
据我所知,localhost上没有邮件服务器,但是我如何制作邮件服务器,如果我不能,那么为什么s = smtplib.SMTP('gmail.com')
如果有效则需要这么长时间?我需要做些什么才能让它发挥作用?任何帮助表示赞赏。
output: >> Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
s = smtplib.SMTP('gmail.com')
File "C:\Python25\lib\smtplib.py", line 244, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python25\lib\smtplib.py", line 310, in connect
raise socket.error, msg
error: (10013, 'Permission denied')
gmail smtp代码耗时太长。