简体   繁体   中英

Python Email Server not responding

Input

 import smtplib
    conn = smtplib.SMTP('imap.gmail.com',587)
    conn.ehlo()
    conn.starttls()
    conn.login('loginmail@gmail.com', 'password')

    conn.sendmail('sender1@gmail.com','sender2@gmail.com','Subject: What you like? \n\n Reply Reply Reply')
    conn.quit()

Output and Error

Traceback (most recent call last):
  File "E:\python\openCV\em.py", line 4, in <module>
    conn = smtplib.SMTP('imap.gmail.com',587)
  File "C:\Users\loges\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 251, in _init_
    (code, msg) = self.connect(host, port)
  File "C:\Users\loges\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Users\loges\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 307, in _get_socket
    self.source_address)
  File "C:\Users\loges\AppData\Local\Programs\Python\Python36\lib\socket.py", line 724, in create_connection
    raise err
  File "C:\Users\loges\AppData\Local\Programs\Python\Python36\lib\socket.py", line 713, in create_connection
    sock.connect(sa)
TimeoautError: [WinError 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

Please help me to solve this issue. It looks like server issue. I have included the login mail and password, 2 sender emails and a subject. I want to send a zip file. The program is showing error and I have provided the error above

You are connecting to the wrong server. Should be:

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

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