简体   繁体   中英

socket.error: [Errno 10060] while sending an email with Python

I am learning Python and wanted to try a small python script where I can send email with that script.

My Code:

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)


server.login("youremailusername", "password")


msg = "Hello! Test Script For Sending an email" 

server.sendmail("you@gmail.com", "target@example.com", msg)

Error Message:

socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Can some one please help me what with problem?

the network you're on might be blocking that port (587) for outgoing connections, or Google might be blocking your IP address. If you're on a VPS, you can check the firewall settings for your system and see if you can open it.

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