Linux – postfix smtp relay script

linuxpostfixscripting

I have a Postfix server and using it with Outlook (POP/SMTP).

I have different sender addresses for an account.
Now I want to configure a relay for a specific sender address.
For example I have postfix for my main domain domain1.com.
Now I have a sender address that is domain2.com.

For that sender address I want that postfix to relay mail to a second SMTP server.
I think that should be possible without problems.

But the problem is that I have to create a SSH tunnel to the second server to connect to the
SMTP server.
But I cant use a persistent SSH connection so I want to know if it is possible that postfix executes some script before relaying the mail to the second SMTP server.

I already found some information for executing a script when incomming emails but I only want to establish the SSH tunnel before postfix relays the mail to the second SMTP server.

Best Answer

Exactly how you implement it is up to you, but you can create your own transport, and that transport can be a script, or daemon, etc.

If you could keep the tunnel up, it would be a breeze, you'd just set an

domain2.com smtp:127.0.0.1:2000 (or whatever port you assigned locally)

transport up.

Related Topic