Back

SMTP Failing with Mailgun on Redis error?

  • 0
  • Self Hosted
  • General
  • Web
ZachHandley
16 Feb, 2024, 16:32
TypeScript
[Worker] Worker 0 is ready!
Worker mails  started

Fatal error: Uncaught RedisException: Connection refused in /usr/src/code/vendor/utopia-php/queue/src/Queue/Connection/Redis.php:181
Stack trace:
#0 /usr/src/code/vendor/utopia-php/queue/src/Queue/Connection/Redis.php(181): Redis->connect('redis', 6379)
#1 /usr/src/code/vendor/utopia-php/queue/src/Queue/Connection/Redis.php(77): Utopia\Queue\Connection\Redis->getRedis()
#2 /usr/src/code/vendor/utopia-php/queue/src/Queue/Connection/Redis.php(66): Utopia\Queue\Connection\Redis->rightPop('utopia-queue.qu...', 5)
#3 /usr/src/code/vendor/utopia-php/queue/src/Queue/Server.php(199): Utopia\Queue\Connection\Redis->rightPopArray('utopia-queue.qu...', 5)
#4 [internal function]: Utopia\Queue\Server->Utopia\Queue\{closure}('0')
#5 /usr/src/code/vendor/utopia-php/queue/src/Queue/Adapter/Swoole.php(37): call_user_func(Object(Closure), '0')
#6 {main}
  thrown in /usr/src/code/vendor/utopia-php/queue/src/Queue/Connection/Redis.php on line 181

so I can't seem to send emails and this is the only error in the mails worker

TL;DR
SMTP is failing with a Mailgun error related to authentication. The Redis error mentioned seems to be unrelated. The user has checked SMTP variables and they are set correctly. They can successfully send emails using the same credentials via command. The problem could be due to a self-signed certificate. The user confirms that the Mailgun credentials are correct. The user provides logs showing Redis errors and a permission denied error related to the Docker socket. They suspect a problem with the server. The Redis connection between the container and Redis is identified as the issue. The user also shares additional environment variables related to SMTP. Possible solutions: - Confirm that all SMTP variables
Steven
16 Feb, 2024, 16:37

weird....this seems to be a connection between the container and redis 🧐

Steven
16 Feb, 2024, 16:37

can you check the env vars and make sure they're set correctly in the container?

ZachHandley
16 Feb, 2024, 16:37

yeah seemingly happened all of the sudden

ZachHandley
16 Feb, 2024, 16:37

lemme check

ZachHandley
16 Feb, 2024, 16:38
TypeScript
_APP_SMTP_HOST=smtp.mailgun.org
_APP_SMTP_PORT=587
_APP_SMTP_SECURE=tls
_APP_SMTP_USERNAME=support@mg.pva.ai
_APP_SMTP_PASSWORD=my_password
ZachHandley
16 Feb, 2024, 16:39

This ones extra weird yeah I agree, I can give you access if you need

Steven
16 Feb, 2024, 16:42

no no. it's not a SMTP problem. It's a redis problem

ZachHandley
16 Feb, 2024, 16:42
TypeScript
_APP_REDIS_HOST=redis
_APP_REDIS_PORT=6379
_APP_REDIS_USER=
_APP_REDIS_PASS=
ZachHandley
16 Feb, 2024, 16:43
TypeScript
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/519ba1fee0d9/json": dial unix /var/run/docker.sock: connect: permission denied

in the redis-alpine

Steven
16 Feb, 2024, 16:44

that's weird...redis shouldn't need the docker socket..

ZachHandley
16 Feb, 2024, 16:44

just restarted

Steven
16 Feb, 2024, 16:44

orrr this might be a problem with the server 🧐

ZachHandley
16 Feb, 2024, 16:45
TypeScript
1:M 16 Feb 2024 16:29:41.175 # User requested shutdown...
1:M 16 Feb 2024 16:29:41.175 * Saving the final RDB snapshot before exiting.
1:M 16 Feb 2024 16:29:41.196 * DB saved on disk
1:M 16 Feb 2024 16:29:41.196 # Redis is now ready to exit, bye bye...
1:C 16 Feb 2024 16:29:57.683 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 16 Feb 2024 16:29:57.683 # Redis version=7.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 16 Feb 2024 16:29:57.683 # Configuration loaded
1:M 16 Feb 2024 16:29:57.683 * monotonic clock: POSIX clock_gettime
1:M 16 Feb 2024 16:29:57.688 * Running mode=standalone, port=6379.
1:M 16 Feb 2024 16:29:57.688 # Server initialized
1:M 16 Feb 2024 16:29:57.688 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 16 Feb 2024 16:29:57.688 * Loading RDB produced by version 7.0.4
1:M 16 Feb 2024 16:29:57.688 * RDB age 16 seconds
1:M 16 Feb 2024 16:29:57.688 * RDB memory usage when created 5.02 Mb
1:M 16 Feb 2024 16:29:57.711 * Done loading RDB, keys loaded: 1262, keys expired: 0.
1:M 16 Feb 2024 16:29:57.711 * DB loaded from disk: 0.023 seconds
1:M 16 Feb 2024 16:29:57.711 * Ready to accept connections
1:M 16 Feb 2024 16:30:58.053 * 10000 changes in 60 seconds. Saving...
1:M 16 Feb 2024 16:30:58.054 * Background saving started by pid 15
15:C 16 Feb 2024 16:30:58.072 * DB saved on disk
15:C 16 Feb 2024 16:30:58.072 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 16 Feb 2024 16:30:58.154 * Background saving terminated with success
1:M 16 Feb 2024 16:35:59.029 * 100 changes in 300 seconds. Saving...
1:M 16 Feb 2024 16:35:59.029 * Background saving started by pid 16
16:C 16 Feb 2024 16:35:59.048 * DB saved on disk
16:C 16 Feb 2024 16:35:59.048 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 16 Feb 2024 16:35:59.130 * Background saving terminated with success
1:M 16 Feb 2024 16:41:00.004 * 100 changes in 300 seconds. Saving...
1:M 16 Feb 2024 16:41:00.004 * Background saving started by pid 17
17:C 16 Feb 2024 16:41:00.023 * DB saved on disk
17:C 16 Feb 2024 16:41:00.023 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
1:M 16 Feb 2024 16:41:00.105 * Background saving terminated with success
ZachHandley
16 Feb, 2024, 16:45

lemme check again

ZachHandley
16 Feb, 2024, 16:46

so idk where that redis error came from, but anyways, this is what I'm getting

TypeScript
[Worker] Worker 0 is ready!
Worker mails  started
[Job] Received Job (65cf912a607b33.25560742).
[Job] (65cf912a607b33.25560742) failed to run.
[Job] (65cf912a607b33.25560742) 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: 96
ZachHandley
16 Feb, 2024, 16:46

issue is, those are the right Mailgun credentials

ZachHandley
16 Feb, 2024, 16:47

could it be because the self-signed cert for some reason?

ZachHandley
16 Feb, 2024, 16:53

I can send an email with a command using the same credentials

Steven
16 Feb, 2024, 16:54

Ahh okay this means it's an SMTP problem. Progress!

Steven
16 Feb, 2024, 16:55

Did you set the email address environment variable? See https://appwrite.io/docs/advanced/self-hosting/email

ZachHandley
16 Feb, 2024, 16:57

The team one? Yeah. All SMTP variables are set same as my other Gmail SMTP server vars

ZachHandley
16 Feb, 2024, 16:58

Does could not authenticate just mean the credentials failed or could it mean other errors are caught as that?

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