Could not connect to SMTP server: SMTP Error: Could not connect to SMTP host.
- 0
- Self Hosted
- General
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
- _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:
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:
[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.
I tried a mail-verification and the logs of the mail-worker is:
[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
In the appwirte logs I do get also the error:
[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
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.
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.
Recommended threads
- Custom Email Templates Not Updating for ...
I have 4 custom email templates on my self-hosted Appwrite instance: - email verification - reset password - security alert - 2FA verification. email verifica...
- Docker compose down command is deleting ...
I just followed the steps in the website...but docker compose down seems to delete whole data...it is like fresh installation. Please check if i am missing anyt...
- Bug Report: type generation for enum of ...
### 👟 Reproduction steps in the enum element value, instead of English, use another language (Khmer), in my case Khmer text. ``` export enum ProvinceType { ...