Skip to content

SMTP Error: Could not authenticate #10696

Closed
Closed

Description

@Luo-En

👟 Reproduction steps

Configure a custom SMTP server as part of the appwrite selfhost docker installation (APP_SMTP*) in the .env file.

👍 Expected behavior

Emails should be send for password recovery or email verification when requested from the console.

👎 Actual Behavior

No emails are generated, instead the (appwrite-worker-mails) log shows

[Job] (68fb524fabcf82.31712895) Error sending mail: SMTP Error: Could not authenticate.
[Error] Type: Exception
[Error] Message: Error sending mail: SMTP Error: Could not authenticate.
[Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
[Error] Line: 173

The same smtp configuration works fine when configured as a custom SMTP server in the project settings and account verification links are generated through the API.

🎲 Appwrite version

Version 1.8.x

💻 Operating system

Linux

🧱 Your Environment

I'm self hosting a fresh install of appwrite 1.8.0 using docker.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Activity

  1. added theissue type on Oct 24, 2025
  2. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    @Luo-En Are you using it for both in the .env variables and also inside the console?

  3. added
    product / self-hosted
    on Oct 27, 2025
  4. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author

    Yes. I configured it as a custom SMTP server for my project and also configured the same server in the .env file for the appwrite instance. It works for the project (when I need it to send out verification emails or mfa codes) but it doesn't work when appwrite itself should send out emails (e.g. when I needed to recover the appwrite admin's password).

  5. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    @Luo-En What if you leave it only for the SMTP? It's still not working?
    What are the env varibales that you have set?
    Also, after setting them, did you recreate the containers with docker compose up -d or `docker compose up -d --force-recreate´?

    What's the result of docker exec appwrite doctor?

  6. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author

    I started with only the SMTP settings in the .env and that didn't work. I was quite surprised to see that it worked in the project settings though.

    I never used compose up-d --force-recreate, just docker compose up -d. Want me to try that?

    [Settings]
    🟢 Hostname is valid ([redacted])
    🟢 CNAME record target is valid ([redacted])
    🟢 A record target is valid (127.0.0.1)
    🟢 AAAA record target is valid (::1)
    🟢 Using a unique secret key for encryption
    🟢 App environment is set for production
    🔴 Abuse protection is disabled
    🟢 Console access limits are enabled
    🔴 HTTPS force option is disabled
    🔴 HTTPS force option is disabled for function/site domains
    🔴 Logging adapter is misconfigured
    
    [Connectivity]
    🟢 Console.DB(console)...............................connected
    🟢 Projects.DB(database_db_main).....................connected
    🟢 Cache(cache_redis_main)...........................connected
    
    Warning: foreach() argument must be of type array|object, null given in /usr/src/code/src/Appwrite/Platform/Tasks/Doctor.php on line 177
    🟢 PubSub(pubsub)....................................connected
    🔴 SMTP...........................................disconnected
    
    [Volumes]
    🟢 Uploads Volume is readable
    🟢 Uploads Volume is writeable
    🟢 Cache Volume is readable
    🟢 Cache Volume is writeable
    🟢 Config Volume is readable
    🟢 Config Volume is writeable
    🟢 Certs Volume is readable
    🟢 Certs Volume is writeable
    
    [Disk Space]
    🟢 Uploads Volume has 991.82GB free space (49.6% used)
    🟢 Cache Volume has 991.82GB free space (49.6% used)
    🟢 Config Volume has 991.82GB free space (49.6% used)
    🟢 Certs Volume has 991.82GB free space (49.6% used)
    
  7. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    Yes, try that. What variables have you set?

  8. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author
    _APP_SMTP_HOST=smtp.resend.com
    _APP_SMTP_PORT=587
    _APP_SMTP_SECURE=false
    _APP_SMTP_USERNAME=resend
    _APP_SMTP_PASSWORD=[redacted]
    
    
  9. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author

    Same problem after docker compose up -d --force-recreate and trying to verify admin's email (also made sure I copied the password from the project settings into the .env file):

    [Job] (68ff5ae18be1b9.45121464) failed to run.
    [Job] (68ff5ae18be1b9.45121464) Error sending mail: SMTP Error: Could not authenticate.
    [Error] Type: Exception
    [Error] Message: Error sending mail: SMTP Error: Could not authenticate.
    [Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    [Error] Line: 173
    
    
  10. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    Try setting those envs:
    _APP_SYSTEM_EMAIL_NAME
    _APP_SYSTEM_EMAIL_ADDRESS

  11. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author

    They were already set. I changed them to match my admin user but still same exception from appwrite-worker-emails.

  12. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    Try this:
    _APP_SMTP_PORT=465
    _APP_SMTP_SECURE=tls

  13. DH-555 commented on Oct 27, 2025

    @DH-555
    Contributor

    After making the change make sure to run docker compose up -d

  14. Luo-En commented on Oct 27, 2025

    @Luo-En
    Author

    Slightly different exception:

    [Job] Received Job (68ff7722d74976.64688351).
    ---- took several minutes ----
    [Job] (68ff7722d74976.64688351) failed to run.
    [Job] (68ff7722d74976.64688351) Error sending mail: SMTP Error: Could not connect to SMTP host.
    [Error] Type: Exception
    [Error] Message: Error sending mail: SMTP Error: Could not connect to SMTP host.
    [Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    [Error] Line: 173
    
    
  15. usmandilmeer commented on Oct 28, 2025

    @usmandilmeer

    SMTP port 587 requires TLS, while port 465 requires SSL.
    You can configure this in your Appwrite .env file as follows:

    Port 587: _APP_SMTP_SECURE="tls"
    Port 465: _APP_SMTP_SECURE="ssl"

    After updating the .env file, run:

    docker-compose up -d --build --force-recreate
    docker compose logs -f appwrite-worker-mails
    

    I’m using this configuration on my Appwrite 1.8.0 instance on a VPS, and it’s working perfectly.

  16. DH-555 commented on Oct 28, 2025

    @DH-555
    Contributor

    @usmandilmeer what of those: the tls one or SSL are you using?

  17. Luo-En commented on Oct 28, 2025

    @Luo-En
    Author

    Both 587/"tls" and 465/"ssl" give me the same exception:

    [Job] Received Job (6900b9fa618753.22982664).
    [Job] (6900b9fa618753.22982664) failed to run.
    [Job] (6900b9fa618753.22982664) Error sending mail: SMTP Error: data not accepted.
    [Error] Type: Exception
    [Error] Message: Error sending mail: SMTP Error: data not accepted.
    [Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    [Error] Line: 173
    
    
    
  18. usmandilmeer commented on Oct 28, 2025

    @usmandilmeer

    @usmandilmeer what of those: the tls one or SSL are you using?

    I am using "tls" with port 587 and it is perfectly for my self hosted appwrite.

  19. usmandilmeer commented on Oct 28, 2025

    @usmandilmeer

    Both 587/"tls" and 465/"ssl" give me the same exception:

    [Job] Received Job (6900b9fa618753.22982664).
    [Job] (6900b9fa618753.22982664) failed to run.
    [Job] (6900b9fa618753.22982664) Error sending mail: SMTP Error: data not accepted.
    [Error] Type: Exception
    [Error] Message: Error sending mail: SMTP Error: data not accepted.
    [Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    [Error] Line: 173
    

    Are you using a self-hosted SMTP server or a third-party provider?

    For debugging, you can try using Gmail SMTP with an app password generated from your Gmail account as the SMTP password.

    The error you’re seeing indicates an issue at the DATA stage of SMTP. This is the step where the email body and headers are sent.

    data not accepted means the SMTP server rejected the email content or refused to accept the email for delivery.

  20. Luo-En commented on Oct 28, 2025

    @Luo-En
    Author

    We're getting closer: tried with gmail and that works. Then generated a fresh API key from resend.com (which is used as the SMTP password), their SMTP server and required username and got the same exception as above ('data not accepted'). So it seems to be something specific when using resend as SMTP server.

  21. usmandilmeer commented on Oct 28, 2025

    @usmandilmeer

    @Luo-En Oh Great for you! This means the resend SMTP server is rejecting the email. In SMTP, sending an email goes through several steps: HELO, MAIL FROM, RCPT TO, DATA, and QUIT. The issue is at the DATA stage, where the SMTP server is rejecting your delivery. This is not an issue with your Appwrite instance.

    Previously, I was using SendPulse, but today I switched to my own custom SMTP server (also configured on the same VPS as my Appwrite:1.8.0 instance.), and it is working perfectly.

  22. Luo-En commented on Oct 28, 2025

    @Luo-En
    Author

    @usmandilmeer What remains is the question why the same configuration then works in my appwrite project settings. Emails generated there work fine (using resend.com). It's not a blocking issue for me now but it might make sense to investigate why the same settings work as an appwrite project SMTP server but not for the appwrite instance (console) itself.

  23. usmandilmeer commented on Oct 28, 2025

    @usmandilmeer

    @Luo-En I think the problem occurs when Appwrite sends emails using Resend—there may be additional headers required by Resend that are causing the delivery to be rejected.

    Currently, if Gmail SMTP is working and your issue with sending emails via the Appwrite instance is resolved, you can use it for Appwrite, while continuing to use Resend for regular emails.

  24. sunny0402 commented on Nov 5, 2025

    @sunny0402

    I also get the SMTP could not authenticate error. I am using Appwrite verssion 1.6.0.

    [Error] Type: Exception
    [Error] Message: Error sending mail: SMTP Error: Could not authenticate.
    [Error] File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    [Error] Line: 145
    

    But I am able to send an email from inside the appwrite-worker-mails container using swaks. Thus confirming SMTP credentials.

    sudo docker compose exec appwrite-worker-mails sh
    apk add --no-cache perl
    curl -O https://jetmore.org/john/code/swaks/files/swaks-20240103.0/swaks
    chmod +x swaks
    apk add --no-cache perl-net-ssleay perl-io-socket-ssl
    perl ./swaks --to [email protected] \
      --from "$_APP_SYSTEM_EMAIL_ADDRESS" \
      --server "$_APP_SMTP_HOST" \
      --port "$_APP_SMTP_PORT" \
      --auth LOGIN \
      --auth-user "$_APP_SMTP_USERNAME" \
      --auth-password "$_APP_SMTP_PASSWORD" \
      --tls
    

    I can also confirm my variables are set.

    ~/appwrite$ sudo docker exec appwrite-worker-mails env | grep _APP_SMTP
    _APP_SMTP_PORT=587
    _APP_SMTP_HOST=smtp.mailgun.org
    [email protected]
    _APP_SMTP_SECURE=tls
    _APP_SMTP_PASSWORD=1234-abcd
    
    ~/appwrite$ sudo docker exec appwrite-worker-mails env | grep _APP_SYSTEM_EMAIL
    [email protected]
    _APP_SYSTEM_EMAIL_NAME=MyAppName
    

    But when I make a request from my frontend to reset a password I get the authentication error. The request goes through with status code 201.

    const response = await account.createRecovery(email, url);
    
    ~/appwrite$ sudo docker compose logs -t appwrite-worker-mails
    appwrite-worker-mails  | Received Job.
    appwrite-worker-mails  |  failed to run.
    appwrite-worker-mails  |  Error sending mail: SMTP Error: Could not authenticate.
    appwrite-worker-mails  |  Using deprecated logging configuration. Please update your configuration to use DSN format.Unable to parse DSN: scheme is required
    appwrite-worker-mails  | [Error] Type: Exception
    appwrite-worker-mails  | [Error] Message: Error sending mail: SMTP Error: Could not authenticate.
    appwrite-worker-mails  | File: /usr/src/code/src/Appwrite/Platform/Workers/Mails.php
    appwrite-worker-mails  | [Error] Line: 145
    
  25. sunny0402 commented on Dec 14, 2025

    @sunny0402

    Fixed my SMTP authentication error. Email setting in the Appwrite console were different from the SMTP values in the .env file of self-hosted instance.

    https://www.sunnyappdev.com/blog/mailgun-smtp-self-hosted-appwrite

  26. Pipe-Runner commented on Feb 11, 2026

    @Pipe-Runner

    @usmandilmeer I just tested it, resend config works for console emails. Tested with TLS and port 587. Sent an invitation link to a project to one of my gmail accounts. Worked as expected. It wasn't working earlier, but I created a new resend API keys and it just started working. Strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / self-hosted

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions