While using my self-hosted VPN setup (Wstunnel + WireGuard + Clash Verge Rev), I found that Thunderbird could not send emails via Gmail, producing the following errors:
“Unable to connect to outgoing server (SMTP) smtp.gmail.com. The server may be unavailable or refusing SMTP connections.”
Or: “The message could not be sent because the connection to the outgoing server (SMTP) smtp.gmail.com timed out.”
Meanwhile, accessing https://mail.google.com through the browser worked perfectly. This indicates that the VPN itself can reach Google, and the issue lies in Thunderbird’s traffic not being proxied correctly.
The core reason is that Clash routing rules do not cover email protocol ports.
My VPN setup uses Clash for traffic routing, and the default rules typically only cover common HTTP/HTTPS ports (80, 443).
Thunderbird uses the SMTP protocol to send emails, operating on port 587 or 465. Because the rules do not explicitly match these ports, Clash routes the traffic to DIRECT (direct connection).
However, my network environment requires a VPN to access the external internet. A direct connection cannot reach Google’s SMTP servers, resulting in a timeout or refused connection.
The browser can access Gmail because web traffic uses port 443, which is caught by the MATCH,Proxy fallback rule in Clash. This creates the situation where “the web interface works, but the email client fails.”
3. Solution
3.1 Verify Thunderbird’s SMTP Settings
First, ensure that Thunderbird’s outgoing server configuration meets Gmail’s requirements, especially OAuth2 authentication (Google has phased out standard password authentication).
Go to Thunderbird’s Account Settings → Outgoing Server (SMTP), and edit the corresponding Gmail outgoing server.
[Screenshot 2: Edit outgoing server window, showing port 465 + SSL/TLS + OAuth2]
[Screenshot 3: Edit outgoing server window, showing port 587 + STARTTLS + OAuth2] (Final recommended configuration)
The following parameters are recommended:
Item
Value
Server Address
smtp.gmail.com
Port
587
Connection Security
STARTTLS
Authentication Method
OAuth2
Username
Full Gmail address
Save the settings, restart Thunderbird, and try sending a test email. If it still fails, proceed to the next step.
3.2 Modify Clash Configuration to Add Email Port Proxy Rules
Open the Clash configuration file (I used the custom rules in my Clash Verge Rev subscription file), locate the rules: field, and insert the following two lines after the local LAN direct connection rules and before the domestic traffic direct connection rules:
Some Wstunnel startup commands only specify forwarding for the WireGuard port (e.g., 51820), preventing other ports (e.g., 587, 465) from reaching the remote server.
Verify whether your Wstunnel startup parameters restrict port forwarding. Typically, the default configuration forwards all TCP ports. If necessary, modify the Wstunnel startup command to remove the port restriction.
5. Summary
The root cause of this issue is that Clash routing rules did not include email ports, causing Thunderbird’s SMTP traffic to use a direct connection. The solution is straightforward: add the following to the rules section of the Clash rules:
YAML
- DST-PORT,587,Proxy- DST-PORT,465,Proxy
This approach also applies to proxy issues with other non-HTTP protocols (such as SSH, gaming, app store updates, etc.)—simply find the corresponding port and add it to the proxy rules.