0

Друзья никак не получается получить почту, выдает следующую ошибку

    Traceback (most recent call last):
      File "C:\Users\user\PycharmProjects\pythonProject1\inet\mail\popchik.py", line 8, in <module>
        server = poplib.POP3(pop3_server)
      File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\poplib.py", line 104, in __init__
        self.sock = self._create_socket(timeout)
      File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\poplib.py", line 112, in _create_socket
        return socket.create_connection((self.host, self.port), timeout)
      File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\socket.py", line 843, in create_connection
        raise err
      File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\socket.py", line 831, in create_connection
        sock.connect(sa)
    TimeoutError: [WinError 10060] 

Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера

Я уверен что вся инфа введена правильно, помоему проблема в настройке google, но я уже прочитал как ее настроить, но там говорят что-то про почтовых клиентов там предлагают настроить POP pop.gmail.com, но к сожалению в microsoft.outlook не получается изменить POP на pop.gmail.com, а вот если что сам код

# import python poplib module
import poplib
# input email address, password and pop3 server domain or ip address
email = input('Email: ')
password = input('Password: ')
pop3_server = input('POP3 server: ')
# connect to pop3 server:
server = poplib.POP3(pop3_server)
# open debug switch to print debug information between client and pop3 server.
server.set_debuglevel(1)
# get pop3 server welcome message.
pop3_server_welcome_msg = server.getwelcome().decode('utf-8')
# print out the pop3 server welcome message.
print(server.getwelcome().decode('utf-8'))
# user account authentication
server.user(email)
server.pass_(password)
# stat() function return email count and occupied disk size
print('Messages: %s. Size: %s' % server.stat())
# list() function return all email list
resp, mails, octets = server.list()
print(mails)
# retrieve the newest email index number
index = len(mails)
# server.retr function can get the contents of the email with index variable value index number.
resp, lines, octets = server.retr(index)
# lines stores each line of the original text of the message
# so that you can get the original text of the entire message use the join function and lines variable.
msg_content = b'\r\n'.join(lines).decode('utf-8')
# now parse out the email object.
msg = Parser().parsestr(msg_content)
# get email from, to, subject attribute value.
email_from = msg.get('From')
email_to = msg.get('To')
email_subject = msg.get('Subject')
print('From ' + email_from)
print('To ' + email_to)
print('Subject ' + email_subject)
# delete the email from pop3 server directly by email index.
# server.dele(index)
# close pop3 server connection.
server.quit()
1
  • вот ссылка где я читал про настройку и не смог по моему настроить google pop [support.google.com/mail/answer/7104828?hl=ru] и еще я читал сообщение что google не разрешит читать если недавно менял пороль и я перед тем как писать этот код его менял 11 мая 2021 в 5:47

1 ответ 1

1

тебе нужно использовать не poplib.POP3 а poplib.POP3_SSL, потому что Требуется SSL: да

https://docs.python.org/3/library/poplib.html

Additionally, this module provides a class POP3_SSL, which provides support for connecting to POP3 servers that use SSL as an underlying protocol layer.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.