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.
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!
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 = "your@email.com",
MAIL_PORT = 587,
MAIL_SERVER = "your mail server",
MAIL_TLS = True,
MAIL_SSL = False,
USE_CREDENTIALS = True
)
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.