0
我知道我有內置的lib「smtplib」在Python中,但我想學習如何做到這一點沒有它, 在閱讀有關此協議後,我試圖喜歡一個代碼示例顯示如何通過python做到這一點,但我找不到任何東西,所以我自己創建了一個,但沒有成功。 這是我的代碼:試圖發送電子郵件通過python與smtp協議沒有成功
import socket
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Connecting to smtp server of google by SSL..."
soc.connect(("smtp.gmail.com", 465))
print "Connected to smtp server of google by SSL!"
print "Sending helo to our friend..."
soc.send("HELO FromX")
print "'helo' went good!"
print "Announcing google about the Sender (us...)..."
soc.send("mail From: [email protected]")
print "I just announced google!"
print "Announcing google about the receiver (us...)..."
soc.send("RCPT To: [email protected]")
print "I just announced google!"
print "Ask google for sending him some data..."
soc.send("DATA")
print "Google accepted us... of course he is, we are handsome!"
print "Now the all other stuff..."
soc.send("From: [email protected]\nTo: [email protected]\nSubject: HEY\n\nBYE\n.")
soc.send("QUIT")
soc.close()
與該代碼,我使用Wireshark是嗤之以鼻: The sniffed information
我會很樂意從你們那裏聽到一些幫助。 (另外,我不知道......我不應該犯一些認證,使谷歌確保它是真的我messege發送者?)
我知道我使用這個庫。但我寫明確我想這樣做,沒有它 –
然後使用電子郵件服務試試吧!內置的mail()函數不能通過python等郵件發送郵件!您需要使用電子郵件服務或SMPT! – gemgr
更喜歡smtp .. tnx –