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

Connection refused to 127.0.0.1:587 when email sending #647

Open
DIG-Tofu opened this issue Nov 11, 2024 · 2 comments
Open

Connection refused to 127.0.0.1:587 when email sending #647

DIG-Tofu opened this issue Nov 11, 2024 · 2 comments

Comments

@DIG-Tofu
Copy link

Hi guys,

I'm contacting you about an issue currently encountered on my wireguard-ui container.

When I would like to send an email with the WG configuration of my user, I receive the following error :
"Mail Error on dialing with encryption type STARTTLS: dial tcp 127.0.0.1:587: connect: connection refused"
Capture

I've attached my docker run command in bottom of the description if needed.

I've questions about that :
Why the container need to reach his loopback address with SMTP protocol ?
I've tried with gmail first but seems working well when i'm doing telnet tests.
I've moved to SendGrid to check if the behavior is the same and it is.

I've dig a lot of topic about this issue but I found anything. Even some AIs don't have the right answer (yeah I've asked to OpenAI...).

sudo docker run -d --name wireguard-ui
--restart=unless-stopped
-p 51820:51820/udp
-p 51821:51821
-p 5000:5000
-v wg-data:/my/own/volumes/wg
-e WG_HOST=192.168.1.100
-e SMTP_HOST=127.0.0.1
-e SMTP_PORT=587
-e SMTP_USERNAME=apikey
-e SMTP_PASSWORD=MY_API_KEY
-e SMTP_FROM=d*****@gmail.com
-e SMTP_FROM_NAME="WireGuard Config"
-e SMTP_ENCRYPTION=starttls
ngoduykhanh/wireguard-ui

Hope it will help.

Best regards,

@b2un0
Copy link

b2un0 commented Nov 12, 2024

in a docker container the loopback interface is the docker container self.

inspect the docker default bridge network interface and use the gateway IP as SMTP_HOST, mostly 172.17.0.1

docker network inspect bridge | grep Gateway

@DIG-Tofu
Copy link
Author

in a docker container the loopback interface is the docker container self.

inspect the docker default bridge network interface and use the gateway IP as SMTP_HOST, mostly 172.17.0.1

docker network inspect bridge | grep Gateway

I've removed the ENV variable SMTP_HOST and I've tried the following docker run command :

The mail seems to be well sent, but when I'm trying to verify the integration with my sendgrid API, it fails, by default I don't receive the mail.

sudo docker run -d
--name wireguard-ui
--restart=unless-stopped
-p 51820:51820/udp
-p 51821:51821
-p 5000:5000
-v wg-data:/home/dosel/dockvolumes/wg
-e WG_HOST=192.XXX.XXX.XXX (IP of the docker server)
-e SENDGRID_API_KEY=SG.xxxxx
-e SMTP_HOST=smtp.sendgrid.net
-e SMTP_PORT=587
-e SMTP_FROM=d********@gmail.com
-e SMTP_FROM_NAME="WireGuard Config"
-e SMTP_ENCRYPTION=starttls ngoduykhanh/wireguard-ui

It seems to be reliable but maybe I've missed a specific variable.

In any cases, thanks by advance for you help.

Tofu

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