# Send mail via SMTP inside a space

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073%3E%5C
**Category:** Spaces\
**Created:** [October 10, 2023, 5:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073 "2023-10-10T17:52:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![giulioook](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@giulioook](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgiulioook)%5C
**Post date:** [October 10, 2023, 5:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073%2F1 "2023-10-10T17:52:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [October 12, 2023, 8:27pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073%2F2 "2023-10-12T20:27:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tysonsoni](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tysonsoni](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftysonsoni)%5C
**Post date:** [July 21, 2024, 3:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073%2F3 "2024-07-21T15:28:46Z")

</div>

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

I use

```auto
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?

---

<div class="post-metadata">

**Author:** ![mancai](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@mancai](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmancai)%5C
**Post date:** [October 14, 2024, 5:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsend-mail-via-smtp-inside-a-space%2F58073%2F4 "2024-10-14T05:45:11Z")

</div>

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