我試圖使用Beaglebone Black(BBB)發送電子郵件通知,但是我遇到了getaddrinfo錯誤,該錯誤讀作如下:當試圖使用Beaglebone Black發送電子郵件時接收getaddrinfo [Errno -2]
socket.gaierror: [Errno -2] Name or service not known
我一直在這個工作了一段時間,並找不到爲什麼這不工作。
納米文件我「米試圖運行:
import smtplib
#import time
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
#time.sleep(1000)
print("SMTP object created...")
smtpObj.ehlo()
#time.sleep(1000)
print("EHLO...")
smtpObj.starttls()
#time.sleep(1000)
print("Starting TLS...")
smtpObj.login('[email protected]', 'EXAMPLEPASSWORD')
#time.sleep(1000)
print("Logged into [email protected]")
smtpObj.sendmail('[email protected]', 'EXAMPLERECIPIENT', '''Subject:test subject \ntest body
Auto Alert System.''')
{}
#time.sleep(1000)
print("Sending email...")
smtpObj.quit()
#time.sleep(1000)
print("Destorying object.")
調用test_email2.py函數的輸出如下:
[email protected]:~/Desktop/email_project# python test_email2.py
Traceback (most recent call last):
File "test_email2.py", line 4, in <module>
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
是基於我一直在下面的格式由https://automatetheboringstuff.com/chapter16/提供
感謝您的第一段,這實際上有助於我理解發生了什麼。 至於第二段,我希望我可以提供這些信息,但我真的不知道任何這些項目的狀態,我不知道如何檢查它們。我可能需要一段時間才能弄明白。 –
@EdSawden,請加入:http://chat.stackoverflow.com/rooms/123476/receiving-getaddrinfo-errno-2-when-trying-to-use-beaglebone-black-to-send-emai 我會試着幫助你。 –
我真的希望我可以聊天,但我需要14個更多的聲望才能夠使用聊天室(至少20聲望;我在6)。 –