Skip to content
Back

Could not connect to SMTP server: SMTP Error: Could not connect to SMTP host.

  • 0
  • Self Hosted
  • General
THE-E
26 Oct, 2025, 15:42

Hi there,

I have currently an issue configuring my SMTP (Custom SMTP server) setting in appwrite. My Setup:

  • Self-hosted (DigitalOcean): appwrite 1.8.0
  • SMTP-Host: Google Workspace (with 2-Faktor authentication)
  • Nginx reverse proxy for the SSL certificates

I have configured all environment variables in the .env file (and obviously restarted). I get the following values for docker compose exec appwrite-worker-mails vars

TypeScript
- _APP_SMTP_HOST=smtp.gmail.com
- _APP_SMTP_PORT=587
- _APP_SMTP_SECURE=tls
- _APP_SMTP_USERNAME=info@example.com
- _APP_SMTP_PASSWORD=****(using an app password)

In appwrite I am unable to set: Custom SMTP server. I keep getting the error:

TypeScript
Could not connect to SMTP server: SMTP Error: Could not connect to SMTP host. Failed to connect to server

It also does not override the settings, when I click on Update. If I reload the page, Custom SMTP server is always deactivated. At the beginning I had values set, which I was able to override by deactivating the Custom SMTP server switch. Now I can't override it. I guess only after validation values are stored in the database?

In the appwrite logs I get:

TypeScript
[Error] Timestamp: 2025-10-26T15:32:06+00:00
[Error] Method: PATCH
[Error] URL: /v1/projects/:projectId/smtp
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Could not connect to SMTP server: SMTP Error: Could not connect to SMTP host. Failed to connect to server
[Error] File: /usr/src/code/app/controllers/api/projects.php
[Error] Line: 2091

I tested the credentials using gotmp and could successfully send mails on the first try (using username and the generated app password).

Two changes to mention: I updated from appwrite 1.7.4 to 1.8.0. Furthermore, I changed the domain of my Google Workspace (but obviously adjusted my variables to login).

I am little clueless, what to check next. It would be really nice, if someone could give me a hint, what I am missing.

TL;DR
Developers faced issue connecting to SMTP host on DigitalOcean, moved to Azure for cheaper option, but needed 1-3 year reservation. Error persists with DigitalOcean for appwrite's custom SMTP settings using Google Workspace - setup seems configured correctly, `gotmp` test successful. Post-updates and domain change, SMTP connection fails. Need help troubleshooting.
THE-E
26 Oct, 2025, 15:54

I tried a mail-verification and the logs of the mail-worker is:

TypeScript
[Job] Received Job (68fe43044768e8.96771826).
[Job] (68fe43044768e8.96771826) failed to run.
[Job] (68fe43044768e8.96771826) Error sending mail: SMTP Error: Could not connect to SMTP host. Failed to connect to server
[Error] Type: Exception
[Error] Message: Error sending mail: SMTP Error: Could not connect to SMTP host. Failed to connect to server
[Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
[Error] Line: 173
THE-E
26 Oct, 2025, 15:56

In the appwirte logs I do get also the error:

TypeScript
[Error] Timestamp: 2025-10-26T15:50:26+00:00
[Error] Method: GET
[Error] URL: /v1/migrations
[Error] Type: Utopia\Database\Exception\Query
[Error] Message: Invalid query: Attribute not found in schema: destination
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 6723
[Error] Timestamp: 2025-10-26T15:52:07+00:00
[Error] Method: GET
[Error] URL: /v1/migrations
[Error] Type: Utopia\Database\Exception\Query
[Error] Message: Invalid query: Attribute not found in schema: destination
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 6723
THE-E
27 Oct, 2025, 13:07

When I successfully tested gomtp with the login data, I was using my local machine. When I used gomtp on the DigitalOcean VM/droplet, with the exact same settings, I was unable to send any mails. So in conclusion I was thinking, maybe DigitalOcean is preventing SMTP in some sort. I found this doc: https://docs.digitalocean.com/support/why-is-smtp-blocked/

Now I am looking into it so I can use SMTP on a appwrite instance in the DigitalOcean cloud.

THE-E
2 Nov, 2025, 23:56

I would like to share my end result, in case someone encounters the same issue.

I had the option to either to use a third party SMTP provider with additional costs or move to a VM which does not have the SMTP limitation.

I didn't wan't to create another expenditure, so third party SMTP providers were out.

The DigitalOcean droplet is basically only a quick start, but does nothing beneficial for maintenance. You end up managing it manually, like every other regular VM.

I decided to switch to the Azure cloud with the combination of Azure reservation, which led to an overall cheaper monthly expenditure compared to DigitalOcean. Because Azure VMs don't block SMTP, I didn't need to pay a third party SMTP provider a fee as well. Downside: I had to commit to a 1-3 year reservation in order to get a cheaper monthly expenditure.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more