Impossible to send emails from web service

Hello, I’m having trouble sending emails from my Python web service which runs on a Digital Ocean droplet (ubuntu 20.04). More specifically, I’m using the fastapi-mail library for sending emails, and I get the following error:

aiosmtplib.errors.SMTPServerDisconnected: Connection lost

The strange thing is that the same code works fine from my local machine, but it continuously fails from the Digital Ocean droplet. Do you have any suggestions?

Thanks in advance.


I’ve just found this Question and I think that I’m experiencing the same issue. I just opened a ticket in the Support Center.

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

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.

Hi @campanamattia,

When configuring, you’ll need to add the following configuration in your conf file

conf = ConnectionConfig(
    MAIL_USERNAME = "YourUsername",
    MAIL_PASSWORD = "strong_password",
    MAIL_FROM = "",
    MAIL_PORT = 587,
    MAIL_SERVER = "your mail server",
    MAIL_TLS = True,
    MAIL_SSL = False,

Can you confirm you have added an actual Mailbox,password? Additionally, I’ll recommend using TLS,SSL and Credentials while port shouldn’t be 25 but 465 or 587.

Additionally, what you’ve found (the question you posted) is true so that might fix your issue as well!

If you provide me with a ticket number, I can try and escalate it from the community.

Regards, KFSys