Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need help

84 views
Skip to first unread message

Shuaib Akhtar

unread,
Oct 23, 2022, 5:07:19 PM10/23/22
to
How to fix Traceback (most recent call last):

  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
line 833, in create_connection

    sock.connect(sa)

TimeoutError: [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

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "C:\Users\i9shu\Downloads\python email bot\email bot.py", line 25,
in <module>

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

  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
line 255, in __init__

    (code, msg) = self.connect(host, port)

  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
line 341, in connect

    self.sock = self._get_socket(host, port, self.timeout)

  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\smtplib.py",
line 312, in _get_socket

    return socket.create_connection((host, port), timeout,

  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
line 833, in create_connection

    sock.connect(sa)

KeyboardInterrupt

 

Process finished with exit code -1073741510 (0xC000013A: interrupted by
Ctrl+C)

eorr

 

Sent from [1]Mail for Windows

 

References

Visible links
1. https://go.microsoft.com/fwlink/?LinkId=550986

Cameron Simpson

unread,
Oct 23, 2022, 7:02:34 PM10/23/22
to
Please try to choose more descriptive subject lines (eg "problem with
sock.connect" or similar). That you want help is almost implicit, and
what the whole list is for.

Anyway, to your problem:

On 23Oct2022 10:19, Shuaib Akhtar <i9sh...@gmail.com> wrote:
> How to fix Traceback (most recent call last):
>   File "C:\Program
> Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\socket.py",
> line 833, in create_connection
>     sock.connect(sa)
> TimeoutError: [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

This usually means that either the host address is legal but incorrect
(there's no host/server listening with that address) or that the port is
incorrect and some firewall is _discarding_ your traffic because of the
wrong port instead of returning a nice "connection refused", which is
usually instant.

Fortunately you've listed your call:

>   File "C:\Users\i9shu\Downloads\python email bot\email bot.py",
> line 25,
> in <module>
>     server = smtplib.SMTP('smtp.gmail.com',2525)

So, I'll try that by hand here:

% telnet smtp.gmail.com 2525
Trying 142.250.4.108...
telnet: connect to address 142.250.4.108: Operation timed out
Trying 2404:6800:4003:c0f::6d...
telnet: connect to address 2404:6800:4003:c0f::6d: No route to host
telnet: Unable to connect to remote host
%

I'd say GMail are rudely dropping traffic to port 2525. Maybe try just
25, the normal SMTP port?

Cheers,
Cameron Simpson <c...@cskk.id.au>

rbowman

unread,
Oct 23, 2022, 9:02:45 PM10/23/22
to
On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:


> I'd say GMail are rudely dropping traffic to port 2525. Maybe try just
> 25,
> the normal SMTP port?

2525 is an alternative to 587, the standard TLS port. 25 and 587 work.

telnet smtp.gmail.com 587
Trying 2607:f8b0:4023:1004::6d...
Connected to smtp.gmail.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP s6-20020a056870ea8600b0010bf07976c9sm13154711oap.
41 - gsmtp
EHLO
501-5.5.4 Empty HELO/EHLO argument not allowed, closing connection.
501 5.5.4 https://support.google.com/mail/?p=helo
s6-20020a056870ea8600b0010bf07976c9sm13154711oap.41 - gsmtp
Connection closed by foreign host.


The EHLO needs a domain. Port 25 is the same.

Cameron Simpson

unread,
Oct 24, 2022, 12:01:36 AM10/24/22
to
On 24Oct2022 01:02, rbowman <bow...@montana.com> wrote:
>On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:
>> I'd say GMail are rudely dropping traffic to port 2525. Maybe try
>> just 25, the normal SMTP port?
>
>2525 is an alternative to 587, the standard TLS port.

Yah. My point was more focussed on GMail's shoddy firewall practices not
returning connection refused.

>25 and 587 work.

Good to know. Thanks!
Cameron Simpson <c...@cskk.id.au>

Peter J. Holzer

unread,
Oct 24, 2022, 5:34:15 AM10/24/22
to
On 2022-10-24 01:02:24 +0000, rbowman wrote:
> On Mon, 24 Oct 2022 10:02:10 +1100, Cameron Simpson wrote:
> > I'd say GMail are rudely dropping traffic to port 2525. Maybe try just
> > 25,
> > the normal SMTP port?
>
> 2525 is an alternative to 587, the standard TLS port.

Port 587 is not the standard TLS port. Port 587 is the standard mail
submission port (i.e., a MUA should use port 587 when sending mail; MTAs
should use port 25 when relaying mails to other MTAs).

Traffic on both port 25 and 587 starts in plain text. The server can
indicate that it supports TLS and the client can then send a STARTTLS
command to start a TLS session.

If you want to start the connection with TLS, you can (usually) use port
465. Like 587, this is only intended for mail submission, not mail
transport.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | h...@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
0 new messages