pwd = "mypassword"
import smtplib
server = smtplib.SMTP('smtp.gmail.com')
server.ehlo()
server.starttls()
server.login("[email protected]",pwd)
msg = "YOUR MESSAGE!"
server.sendmail("[email protected]", "[email protected]", msg)
server.quit()
我曾尝试过蟒蛇发送邮件...
错误:
错误在python发送邮件
Traceback (most recent call last):
File "H:/my projects/PythonCourse/test_cont/mail_test4.py", line 4, in <module>
server = smtplib.SMTP('smtp.gmail.com')
File "C:\Python27\lib\smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\lib\smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "C:\Python27\lib\socket.py", line 557, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11001] getaddrinfo failed
我通过代理连接
我在设置代理通过CMD连接视窗。 请帮我这个。
更新:
我相信与互联网连接:
import urllib2
def internet_on():
try:
response=urllib2.urlopen('https://www.google.co.in',timeout=1)
return True
except urllib2.URLError as err: pass
return False
print internet_on()
输出是True
是它的工作没有代理?也许问题是你的代理,而不是Python代码。 – furas
看起来你没有正确的DNS解析,这对代理网络来说并不少见。不幸的是,我们不能给出建议,因为a)我们对您的网络一无所知,并且b)网络配置问题超出了SO的范围。 –
请查看更新 – dharmista