kylegrantlucas / discord-smtp-server

A simple SMTP-Discord Webhook relay.
MIT License
2 stars 2 forks source link

HTTP 401 Unauthorized, {"message": "401: Unauthorized", "code": 0} #2

Open psyciknz opened 1 year ago

psyciknz commented 1 year ago

Getting an unauthorised.

I tried the following docker compose:

services:
  discord-smtp:
    container_name: discord-smtp
    image: kylegrantlucas/discord-smtp-server
    restart: always
    environment:
      - DISCORD_TOKEN=${DISCORD_TOKEN}
      - SMTP_USERNAME=username
      - SMTP_PASSWORD=password
    ports:
      - "2525:1025"

It starts, and if I (using thunderbird) set the account user as username and password as password I get the 401 Unauthorized.

I assume that's from th SMTP side. If get the password wrong or set any of the other options thunderbird will tell me about it.

I also tried the sample telnet:

EHLO localhost
AUTH PLAIN
AHVzZXJuYW1lAHBhc3N3b3Jk
MAIL FROM:<test@test.com>
RCPT TO:<smtp@alert.karenplankton>
DATA
Hey
.

And got the same mesage.

discord-smtp    | 2022/12/02 01:48:58 HTTP 401 Unauthorized, {"message": "401: Unauthorized", "code": 0}

That's not from discord is it? There's no mention of how and where to get the token from - which I got the authorization token using this method: https://linuxhint.com/get-discord-token/#:~:text=Discord%20tokens%20act%20as%20an,creates%20a%20new%20Discord%20account.

psyciknz commented 1 year ago

I think it might have been the discord side.

So created an application and a bot with some permissions and a token. Seem to be getting this error now:

I didn't know what I was doing so it could have been anything

discord-smtp    | smtp/server 2022/12/02 02:22:49 panic serving 192.168.10.147:54221: runtime error: invalid memory address or nil pointer dereference
discord-smtp    | goroutine 52 [running]:
discord-smtp    | runtime/debug.Stack(0xc0001919a0, 0x0, 0x0)
discord-smtp    |       /usr/local/go/src/runtime/debug/stack.go:24 +0x9f
discord-smtp    | github.com/emersion/go-smtp.(*Conn).handle.func1(0xc0001919a0)
discord-smtp    |       /build/vendor/github.com/emersion/go-smtp/conn.go:100 +0xfb
discord-smtp    | panic(0x72e280, 0x9a68b0)
discord-smtp    |       /usr/local/go/src/runtime/panic.go:969 +0x1b9
discord-smtp    | github.com/kylegrantlucas/discord-smtp-server/smtp.(*Session).Rcpt(0xc000636780, 0xc0002811e9, 0xd, 0x3, 0xc0002811e9)
discord-smtp    |       /build/smtp/smtp.go:70 +0x9f
discord-smtp    | github.com/emersion/go-smtp.(*Conn).handleRcpt(0xc0001919a0, 0xc0002811e5, 0x12)
discord-smtp    |       /build/vendor/github.com/emersion/go-smtp/conn.go:494 +0x13e
discord-smtp    | github.com/emersion/go-smtp.(*Conn).handle(0xc0001919a0, 0xc0002811e0, 0x4, 0xc0002811e5, 0x12)
discord-smtp    |       /build/vendor/github.com/emersion/go-smtp/conn.go:130 +0x8d6
discord-smtp    | github.com/emersion/go-smtp.(*Server).handleConn(0xc000122000, 0xc0001919a0, 0x0, 0x0)
discord-smtp    |       /build/vendor/github.com/emersion/go-smtp/server.go:154 +0x1ca
discord-smtp    | created by github.com/emersion/go-smtp.(*Server).Serve
discord-smtp    |       /build/vendor/github.com/emersion/go-smtp/server.go:126 +0xf8