You put put a machine at mail.outhost.net that relays traffic on the POP3 port to pop.yandex.ru, the IMAP4 port to imap.yandex.ru, and so on.
Turn on IP forwarding (otherwise the kernel will drop redirected packets):
echo 1 >/proc/sys/net/ipv4/ip_forward
Relay port 110 to pop.yandex.ru:
iptables -t nat -A PREROUTING -p tcp --dport 110 -j DNAT --to-destination pop.yandex.ru
iptables -t nat -A POSTROUTING -p tcp -d W --dport 110 -j MASQUERADE
There are a number of problems with this:
- You now have a new machine you have to maintain.
- The bandwidth to this host is 2x the bandwidth to Yandex's servers. That may be a lot!
- You have a single point of failure.
- If Yandex changes their IP address (or uses multiple IPs) you will always be chasing Yandex.
If I were to use this technique, I would only use it to find users that haven't changed their configuration yet. Keep good logs of which IP addresses use this service and make sure you track these people down and configure their machines correctly as soon as possible.
I do not recommend using this technique as a permanent solution. If you are so overloaded that your "temporary" solutions often turn into permanent solutions, do not do this at all. Instead, let people be without email for a while as you visit each machine to configure it properly. If Yandex has a web-mail option, they can use that while they wait. Reconfiguring the clients is something that could be automated with PowerShell; you shouldn't actually visit each machine.
For a new configuration, you might consider using hostnames like
imap.yourcompany.com. Make those CNAMEs to the Yandex servers. If you have a very large company, you might consider creating a CNAME for each user so that
pop-madhatter.youcompany.com is a CNAME that can be pointed at any particular server. In the future you'll be able to move users one at a time.