简体   繁体   中英

How to solve: socket.gaierror: [Errno 11001] getaddrinfo failed

import smtplib

my_email = "NAME@gmail.com"
password = "PASSWORD"

receiver = "NAME@yahoo.com"

connection = smtplib.SMTP("smpt.gmail.com")
connection.starttls()
connection.login(user=my_email, password=password)
connection.sendmail(from_addr=my_email, to_addrs=receiver, msg="hello matafakha")
connection.close()

this is a code that i wanted to test, i am new to python and working with the smptlib, how do i solve this error?

connection = smtplib.SMTP("smpt.gmail.com")

You have a typo here. It should be:

connection = smtplib.SMTP("smtp.gmail.com")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM