When using a self-built VPN scheme (Wstunnel + Wireguard + Clash Verge Rev), I found that Thunderbird cannot send mail through Gmail, and the error is as follows:
‘Unable to connect to the outgoing server (SMTP) smtp.gmail.com, the server may be temporarily unavailable, or the SMTP connection is denied.’
Or: ‘Messages were not sent because the connection with the sending server (SMTP) smtp.gmail.com timed out.’
At the same time,Access via browser https://mail.google.com But completely normal. This means that the VPN itself can connect to Google, and the problem is that the traffic of Thunderbird is not properly proxyed.
[截图 1:Thunderbird 发送失败的错误弹窗]
2. Cause analysis
The core reason is The Clash shunt rule does not override the mail protocol port.
My VPN scheme uses Clash for traffic shunting, and the default rules usually only overwrite common ports (80, 443) for HTTP/HTTPS.
Thunderbird send mail usage SMTP protocol, the port is 587 Or 465. Since these ports are not explicitly matched in the rules, traffic is routed to Clash directed(directly connected).
My network environment has to go through a VPN to access the external network, and when it is directly connected, I cannot connect to Google’s SMTP server, resulting in a timeout or denial of connection.
The browser can access Gmail because the web traffic is port 443, which is in the Clash rules. match, proxy The bottom is dealt with. Therefore, the phenomenon of ‘the web page is normal, the mail client fails’.
The solution
3.1 Confirm the SMTP settings for Thunderbird
First, make sure that Thunderbird itself is configured to meet Gmail’s requirements, especially OAuth2 certification(Google has phased out normal password authentication).
Go to Thunderbird account settings → Send Server (SMTP), edit the corresponding Gmail sending server.
After saving, restart Thunderbird and try to send a test email. Still fail, go on to the next step.
[截图 4:Thunderbird 发送失败的错误弹窗]
3.2 Modify the Clash configuration and add mail port proxy rules
Open the Clash configuration file (I am using the custom rules in the Clash Verge Rev subscription file), find Rules: field, in After the local area network direct connection rules,Before the domestic traffic direct connection rules Insert the following two lines:
Only the Wireguard port is specified in some wstunnel startup commands (such as 51820) forwarding, causing other ports (such as 587,465) cannot reach the remote server.
Check if your wstunnel startup parameters limit port forwarding. Normally, the default configuration will forward all TCP ports. If necessary, modify the wstunnel startup command to remove port restrictions.
5. Summary
The root cause of this problem is The Clash split rule does not contain mail ports, causing Thunderbird’s SMTP traffic to go straight. The solution is also very direct: in the Clash rules rules Partially add:
- DST-PORT,587,Proxy
- DST-PORT,465,Proxy
This idea also applies to proxy problems for other non-HTTP protocols (such as SSH, games, app store updates, etc.) – just find the corresponding port and add it to the proxy rules.
Refuse to toss | Exclusive WireGuard VPN generation service
This channel has long measured various network optimization plans.The self-use line has been running continuously and steadily for more than 1 month, and there is no disconnection record in the whole process. If you don’t want to step on the pit and toss the complicated server and protocol configuration repeatedly, please contact me for an exclusive solution.
Service content: ✅ Remote construction: Deploy a dedicated VPN on your own server, complete data control, once and for all. ✅ Free trial benefits: New users can applyFree trial for a month of my self-built node, to experience the ultimate stability and speed. ✅ Effect guarantee: Deeply optimize the shunting rules to completely solve the problem of stuck and connection timeouts in daily use.