این صفحه هنوز به فارسی در دسترس نیست و به زبان انگلیسی نمایش داده میشود.
Reach an SMTP server through Localtonet
در این صفحه 10 بخش
Give the SMTP server on your machine a public host name and port with a TCP tunnel, so mail clients, applications and devices outside your network can submit mail to it or test against it.
What a tunnel can and can't do for mail #
A TCP tunnel forwards incoming connections from its public address to your SMTP server. That covers these cases:
- An application, a device or a mail client outside your network sends mail through your own SMTP server.
- You test a mail server, or a mail-catching tool for development, from another network.
A tunnel does not make your machine a public mail server for a domain. Other mail servers deliver mail for a domain to port 25 of the host in its MX record. The public port of a tunnel is assigned by Localtonet or chosen from 501 to 65535, so it can't be 25. A tunnel also only carries incoming connections: the mail your server sends out still leaves through your own internet connection, and whether it is accepted depends on that connection's IP address and your domain's mail records. Localtonet doesn't change either.
SMTP ports #
| Port | Used for | Encryption |
|---|---|---|
587 | Mail submission: clients and applications sign in and hand over mail to send. The usual choice for a tunnel. | Starts unencrypted, then upgrades with STARTTLS. |
465 | Mail submission, as on 587. | TLS from the first byte (implicit TLS). |
25 | Relay between mail servers. Your server listens here for mail from other servers. | Optional STARTTLS. |
Tunnel the port that your clients are meant to use. If you need two of them, create one tunnel for each. This page uses a TCP tunnel, which works for all three. For a port that speaks TLS from the first byte, such as 465, a TLS tunnel is the other option.
Before you start #
- A Localtonet account and the Localtonet client connected with your AuthToken. See Quick start.
- An SMTP server that is running on the device and requires a user name and password on its submission port.
Create the tunnel #
-
Open the TCP - UDP page #
Open My Tunnels › TCP - UDP and expand Create TCP - UDP Tunnel.
-
Fill in the form #
Field What to enter Protocol TCP Device token The token the Localtonet client on the device uses. Server region Choose a region close to your device for lower latency. Local IP address 127.0.0.1when the SMTP server runs on the same device as the client. For a mail server on another machine in the network, enter that machine's address.Local port The port your SMTP server listens on: 587,465or25.URL type Random subdomain. Custom subdomain lets you choose the name and needs Balance. Domain localto.net, or one of the domains you added in DNS Manager.Select Create tunnel.
-
Start the tunnel and copy the address #
The tunnel appears under Your tunnels. Select Start. The URL column shows the public address as
host:port, and the Server Port column shows the port on its own.
Test the connection #
Run these from a computer outside your network. For a server that uses STARTTLS (the port 587 style):
openssl s_client -starttls smtp -connect <TUNNEL_HOST>:<TUNNEL_PORT>For a server that uses implicit TLS (the port 465 style):
openssl s_client -connect <TUNNEL_HOST>:<TUNNEL_PORT>In both cases you should see the server's certificate and a line that starts with 250 or 220. Type QUIT to leave.
To send a test message with authentication, swaks does the whole exchange and prints it. It asks for the password:
swaks --server <TUNNEL_HOST> --port <TUNNEL_PORT> --tls \
--auth-user <SMTP_USER> \
--from <FROM_ADDRESS> --to <TO_ADDRESS>Use --tlsc instead of --tls for an implicit TLS port.
Set up a mail client or an application #
| Setting | Value |
|---|---|
| Outgoing (SMTP) server | <TUNNEL_HOST> |
| Port | <TUNNEL_PORT>, not 587 or 465 |
| Connection security | STARTTLS if the local port is 587, SSL/TLS if it is 465 |
| Authentication | The user name and password of your SMTP server |
The certificate of your mail server is issued for the server's own name, not for the tunnel's host name. Clients that check the name show a certificate warning or refuse to connect. For a test you can accept the warning. For regular use, put the tunnel on a name you have a certificate for, with Custom subdomain and your own domain. See Custom domains.
Keep the same address #
The host name stays with the tunnel. The port is assigned by the server when the tunnel starts. With Is Reserved? on in the tunnel's Settings, the port stays the same when the tunnel or the Localtonet client restarts, which is what saved mail settings need. With it off, the port changes on a restart. Tunnels that you create while your account has Balance start with Is Reserved? on. Turning it on needs Balance and a started tunnel.
With Balance you can also choose the port under Server Port › Change, for example 587 if no other tunnel on that server uses it. Ports up to 500, which includes 25 and 465, can't be chosen. See Ports.
Free plan. A TCP tunnel stops after 30 minutes on the Free plan and can be started again. The port can be different after each start. See Plans and Balance.
Secure it #
Never expose an SMTP server that relays without authentication. A started tunnel is reachable by anyone who has its address. An open relay is found and abused for spam within a short time, and your internet connection's IP address ends up on blocklists.
- Require authentication and TLS on the port you tunnel.
- Don't rely on "trusted local network" rules. Connections through the tunnel arrive from the Localtonet client on your device, so your mail server sees them as local (
127.0.0.1when the client runs on the same machine). Many mail servers let local addresses relay without signing in. Check that setting before you start the tunnel. - IP Restriction. In the tunnel's Settings, select IP Restriction › Manage, choose Allow only these and add the addresses of the clients that send mail. Use my IP fills in your current address. Changes apply right away. IP Restriction needs Balance. See Access control.
- Limits. Expiration Date, Bandwidth Limit and Speed Limits in the tunnel's Settings cap how long and how much the tunnel can be used. See Limits and expiration.
- Request Log › Show lists the connections made to the tunnel with the visitor's IP address.
Common problems #
The connection times out or is refused
Check that the tunnel is started and its Connection column shows ON, that you use the current port from Server Port, and that the SMTP server answers on the device at the tunnel's Local IP address and Local port.
openssl connects but shows no certificate, or the handshake fails
The TLS style doesn't match the port. Use -starttls smtp for a STARTTLS port and leave it out for an implicit TLS port.
The mail client warns about the certificate
The certificate's name is not the tunnel's host name. See Set up a mail client or an application.
Mail that other servers send to my domain doesn't arrive
Other mail servers deliver to port 25 of your MX host, and a tunnel's public port can't be 25. A tunnel is not a replacement for a mail server that is reachable on port 25.
Mail I send is rejected or lands in spam
Outgoing mail leaves through your own internet connection, not through the tunnel. Acceptance depends on that connection's IP address and on the mail records of your domain.
The tunnel stopped by itself after half an hour
On the Free plan a TCP tunnel stops after 30 minutes. Select Start to begin another session, or add Balance to remove the session limit.
"You need to purchase balance to use this feature."
Is Reserved?, Server Port, IP Restriction and Custom subdomain need Balance. Add it under Balance.