ngoduykhanh / wireguard-ui

Wireguard web interface
MIT License
4.22k stars 517 forks source link

Connection refused to 127.0.0.1:587 when email sending #647

Open DIG-Tofu opened 4 days ago

DIG-Tofu commented 4 days ago

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 commented 3 days ago

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 commented 3 days ago

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