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