Error when trying to send email via SMTP with Directus and Docker

168 Views Asked by At

I have Directus installed in a Docker Container running on a Linode instance. I am trying to send an email from the Directus instance using SMTP as the method but I am getting an error.

I am desperate for help with this error when trying to trigger this endpoint:

https://domain/directus/auth/password/request

Error:

POST /auth/password/request 204 102ms
WARN: [email] Error: write EPIPE
    err: {
      "type": "Error",
      "message": "write EPIPE",
      "stack":
          Error: write EPIPE
              at afterWriteDispatched (node:internal/stream_base_commons:160:15)
              at writeGeneric (node:internal/stream_base_commons:151:3)
              at Socket._writeGeneric (node:net:962:11)
              at Socket._write (node:net:974:8)
              at writeOrBuffer (node:internal/streams/writable:392:12)
              at _write (node:internal/streams/writable:333:10)
              at Writable.write (node:internal/streams/writable:337:10)
              at LastNewline.ondata (node:internal/streams/readable:777:22)
              at LastNewline.emit (node:events:517:28)
              at addChunk (node:internal/streams/readable:335:12)
      "errno": -32,
      "code": "EPIPE",
      "syscall": "write"
    }

docker-compose.yml config for SMTP

EMAIL_SMTP_HOST: "hostname"
EMAIL_SMTP_PORT: "465"
EMAIL_SMTP_USER: "user@website"
EMAIL_SMTP_PASSWORD: "password"
EMAIL_SMTP_POOL: "true"
EMAIL_SMTP_SECURE: "true"
EMAIL_SMTP_IGNORE_TLS: "false"
EMAIL_SMTP_NAME: "hostname"

Does anyone know how to debug this issue?

1

There are 1 best solutions below

0
RipzCurlz On

I found the solution.

If you run into the same issue, here are the two Directus Config Options I had missed when trying to set up SMTP for Directus running on Docker.

EMAIL_TRANSPORT: "smtp"
EMAIL_FROM: "[email protected]

Add these to your docker-compose.yml file and your SMTP connection should work correctly.