Question

While send email network is unreachable

I am hosting a Django web application on my DigitalOcean Droplet and need to send emails using Gmail SMTP. However, my server cannot connect to smtp.gmail.com on ports 587 and 465.

When I run telnet smtp.gmail.com 587, it fails with “Connection timed out.” However, ping smtp.gmail.com works, confirming that my network is reachable.

Please unblock outbound SMTP traffic on ports 587 and 465 for my server so I can send emails.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
March 23, 2025

Hey there 👋

By default, DigitalOcean blocks outbound SMTP traffic on ports 25, 465, and 587 to prevent spam and abuse. That’s why your connection to smtp.gmail.com is timing out.

You can either switch to sending emails via a third-party email API provider like SendGrid or Mailgun, or reach out to support and request an unblock — though unblocking is not always guaranteed: 👉 https://do.co/support

More info here: 👉 https://docs.digitalocean.com/support/why-is-smtp-blocked/

- Bobby

KFSys
Site Moderator
Site Moderator badge
March 23, 2025

Heya,

In order to battle spam DigitalOcean has closed mails ports. What you can try is to contact them and ask for the resriction to be uplifted for your account.

alexdo
Site Moderator
Site Moderator badge
March 24, 2025

Heya, @rashmijoshi

As you have heard the SMTP ports are now closed for sending emails.

I believe you can use the The Gmail API for authentication and lets you send emails using HTTPS over port 443.

You can find more information here:

https://developers.google.com/gmail/api/guides/sending

Hope that this helps!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.