Send mail via SMTP inside a space

hello!

i’m trying to send a mail with yagmail, but every time i get back

File “/usr/local/lib/python3.10/socket.py”, line 833, in create_connection
sock.connect(sa)
OSError: [Errno 101] Network is unreachable

the same simple function is working inside google colab, my pc… only here is not working.

maybe there is some firewall block? can someone help me please?

thank you

SMTP default port numbers are block, you can try running your service from a different port above 1024

@radames I also get an OSError: [Errno 101] Network is unreachable

I use

context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
    server.login(sender_email, email_password)
    server.sendmail(sender_email, receiver_email, text)

Which port can I use and how do I have to change the code?

2 Likes

Which port can I use and how do I have to change the code?