Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring SMTP crashes the pds docker container #164

Open
madsenandersc opened this issue Nov 28, 2024 · 3 comments
Open

Configuring SMTP crashes the pds docker container #164

madsenandersc opened this issue Nov 28, 2024 · 3 comments

Comments

@madsenandersc
Copy link

I have installed the PDS on a clean Debian 12 server, and regardless of what I do, setting up SMTP on an external server crashes the pds container every time.

I used this installer script:
wget https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh

I have tried adding the example lines from the documentation (the resend-example), and even that crashes the container on start:

/app/node_modules/.pnpm/@atproto[email protected]/node_modules/@atproto/pds/src/config/config.ts:146
throw new Error(
^

Error: Partial email config, must set both emailFromAddress and emailSmtpUrl
at envToCfg (/app/node_modules/.pnpm/@atproto[email protected]/node_modules/@atproto/pds/src/config/config.ts:146:13)
at main (/app/index.js:14:15)
at Object. (/app/index.js:72:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49

Node.js v20.11.1

The lines I have added to /pds/pds.env are:

PDS_EMAIL_FROM=[email protected]
PDS_EMAIL_SMTP_URL=smtps://resend:[email protected]:465/

I have tried with the actual information for my email server in this form as well:

PDS_EMAIL_SMTP_URL=smtps://[email protected]:[email protected]:587/

  • and the same happens.

The email address, the server domain as well as the password has been checked and double checked and triple checked and they are all valid. The file is being edited with either nano or vi and there should be no weird chars anywhere.

If I comment out the PDS_EMAIL_SMTP_URL the container runs as expected, so the PDS-EMAIL-FROM seems to be accepted.

@madsenandersc madsenandersc changed the title Configuring SMTP crashes the docker container Configuring SMTP crashes the pds docker container Nov 28, 2024
@BtbN
Copy link

BtbN commented Dec 1, 2024

It's PDS_EMAIL_FROM_ADDRESS.
I also think if your username contains an @ or other special characters, you'll need to escape that somehow.

@madsenandersc
Copy link
Author

For crying out loud! Talk about making a rookie mistake.

You are correct - I had for some stupid reason omitted the "_ADDRESS" after the PDS_EMAIL_FROM.

That brought me further, and eventually I found that it is probably the SMTP server that I use at my hosting company (Hetzner in Germany) that is a bit weird: When setting up a mail client (Evolution in my case), they default to SMTPS on port 587, but using that in the PDS_EMAIL_SMTP_URL just ended in an internal server error.

A dive into the docker log, I found that the problem was a timeout - "Greeting never received".

Eventually I tried setting port 465, even though there is a lot of discussions and articles that talks about port 465 being blocked on Hetzner mailservers, and - honestly, to my surprise - the mail went through with flying colors. No escaping, no nothing.

So, to summarize:

If you are using an external SMTP server that is not a service like Resend or the likes, you can simply add the login information to your SMTP-server to pds.env like this:

PDS_EMAIL_SMTP_URL=smtps://[email protected]:[email protected]:465/

You do not need to escape the "@" in the username or e.g. a "!" in the password - it simply works as is.

If you use port 587 and receive a timeout, try falling back to the deprecated (by almost three decades) port 465 instead - that may work.

@BtbN - thanks a ton for your help, I was really tearing whatever few hairs are still on my head out in frustration.

@BtbN
Copy link

BtbN commented Dec 2, 2024

Port 465 is smtps, straight up TLS encrypted like https. It's not deprecated, but even recommended these days, since downgrade attacks are just out the window from the get go.
Port 587 is plaintext, but can and will be upgraded immediately via STARTTLS.

There's also port 25, which is where mailservers talk to each other on.
If you are running on a server which itself is a MTA, that's where you will want to send your mail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants