Search code examples
phpemailsmtpportforward

Is there a way to passthru SMTP sendings to another server?


we currently got a problem with our company smtp-server and our admin is currently not available. So I wanted to try to send the mails from another server. On our main server there is no connection possible due to a blacklist entry on our own system. So is there a way that I have in my script a server B that listens to this request and send this to the real smtp-server?

So that I can set my connection settings on Server A in PHPMailer to Server B and the B-Server then forwards/passes through the request to the SMTP-Server?

Does anyone knows help?

The problem ist not on Server A. A ping and telnet to all SMTP-Ports of other servers is possible. But a ping or telnet from Server B is possible.

I am thankful for any idea.

Thanks, Robin


Solution

  • I just port-forwarded the requests from one to another server with iptables.

    sysctl net.ipv4.ip_forward=1
    iptables -t nat -A PREROUTING -s 1xx.xx.xx.xx -p tcp --dport 587 -j DNAT --to-destination 2xx.xx.xx.xx:587
    iptables -t nat -A POSTROUTING -j MASQUERADE
    

    Just replaced the placeholders with my two IP addresses and use the new server as relay for sending mails with smtp.

    Thanks, Robin