The question actually consists of several very broad questions, therefore I give only a brief and superficial description of the necessary global steps.
Below I will use the abbreviations from the article Email agent (infrastructure) , in it you can find examples of implementations of certain agents in the links.
- In order to use mua to read the messages received by user
user1@corporate.lan , you need to communicate with the configured maa (there are no articles on the mail access agent in Wikipedia; therefore, for descriptions and examples of implementations, see the articles about the protocols used for communication with maa : imap and pop ) - in order to send a message to user
user1@corporate.lan using mua, you need a connection with the configured mta (using the smtp protocol) - The
corporate.lan domain in the mta settings should be described as localdomain so that the messages are stored locally, where maa can read them. - so that messages addressed to users not from the local domain (s) are sent to a Yandex (or any other) server, you need to set this server as a smarthost with authorization (or, if the server allows, without one) in the mta settings, but the reverse one ( local) address must be replaced with a globally accessible (in your case -
anton9009@yandex.ru ) - messages received by
anton9009@yandex.ru will need to be retrieved from Yandex maa using mra , and redirected to user1@corporate.lan . often for these two tasks use a bunch of fetchmail + procmail ( example )
Considerations for different local senders and responses to their messages:
because when sending a smarthost (i.e., to the outside world), the return (non-existent to the outside world) address must be replaced with a workable (in your case, anton9009@yandex.ru ), the response messages can be forwarded only to some one local user.