multiple/simultaneous virtual_transports?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple/simultaneous virtual_transports?

B. Reino
Hello,

I currently host three virtual domains with a postfix instance. Delivery
is, for all accounts, to a (local, using unix socket) dovecot server using
LMTP.

For one of those virtual domains I'd like to have a separate (remote)
dovecot server, while keeping the SMTP (postfix) at the current server.

Thus I'd need something like:
  virtual_transport = lmtp:[hostname]:port
   (if recipient is in the now-external domain)
   (using [] to deliver via lmtp to hostname directly)

  virtual_transport = lmtp:unix:private/dovecot-lmtp
   (otherwise)

I believe the correct way to do this is defining the default virtual
transport with
  virtual_transport = lmtp:unix:private/dovecot-lmtp

and then:
  transport_maps = hash:/etc/postfix/virtual_transport

having in /etc/postfix/virtual_transport
  external.domain lmtp:[hostname]:port

Q1) does the above make sense?
i.e. will it work as intended (as explained above), so that e.g. if the
(valid, as otherwise rejected) recipient domain is not found in the hash
table then the (default) virtual_transport will be used?

(otherwise, and assuming the above would work, I could just define the
remaining domains also in the table, but I'd prefer keeping it as generic
as possible).

Q2) would it also be possible to -- during a testing period -- have TWO
virtual_transports for a single virtual domain?

This way I could deliver via LMTP to the existing server (via unix socket)
as well as to the new remote server (lmtp via inet).

Thanks a lot in advance for any replies or clarifications!
Reply | Threaded
Open this post in threaded view
|

Re: multiple/simultaneous virtual_transports?

Noel Jones-2
On 9/4/2018 11:42 AM, B. Reino wrote:

> Hello,
>
> I currently host three virtual domains with a postfix instance.
> Delivery is, for all accounts, to a (local, using unix socket)
> dovecot server using LMTP.
>
> For one of those virtual domains I'd like to have a separate
> (remote) dovecot server, while keeping the SMTP (postfix) at the
> current server.
>
> Thus I'd need something like:
>  virtual_transport = lmtp:[hostname]:port
>   (if recipient is in the now-external domain)
>   (using [] to deliver via lmtp to hostname directly)
>
>  virtual_transport = lmtp:unix:private/dovecot-lmtp
>   (otherwise)
>
> I believe the correct way to do this is defining the default virtual
> transport with
>  virtual_transport = lmtp:unix:private/dovecot-lmtp
>
> and then:
>  transport_maps = hash:/etc/postfix/virtual_transport
>
> having in /etc/postfix/virtual_transport
>  external.domain lmtp:[hostname]:port
>
> Q1) does the above make sense?
> i.e. will it work as intended (as explained above), so that e.g. if
> the (valid, as otherwise rejected) recipient domain is not found in
> the hash table then the (default) virtual_transport will be used?
>
> (otherwise, and assuming the above would work, I could just define
> the remaining domains also in the table, but I'd prefer keeping it
> as generic as possible).
>
> Q2) would it also be possible to -- during a testing period -- have
> TWO virtual_transports for a single virtual domain?
>
> This way I could deliver via LMTP to the existing server (via unix
> socket) as well as to the new remote server (lmtp via inet).
>
> Thanks a lot in advance for any replies or clarifications!



To override the transport for a single recipient, use a
transport_maps entry with the recipient address as the key. No
change needed for the existing virtual_transport.

something like:
# /path/to/transport_file
[hidden email]  lmtp:[someotherhost]:port

# main.cf
transport_maps = hash:/path/to/transport_file

===

Delivering one mail to multiple servers is more complicated.  Add a
virtual_alias_maps entry to add a second recipient for the message,
then deliver the second recipient to the alternate server.  If
necessary, you can use lmtp_generic_maps to rewrite the recipient
back to the original name during delivery.

# virtual_alias
[hidden email]   [hidden email]  [hidden email]

# transport
[hidden email]  lmtp:[other.example.com]:port

# lmtp_generic
other.example.com  example.com

# main.cf
virtual_alias_maps = hash:/path/to/virtual_alias
transport_maps = hash:/path/to/transport
lmtp_generic_maps = hash:/path/to/lmtp_generic



  -- Noel Jones
Reply | Threaded
Open this post in threaded view
|

Re: multiple/simultaneous virtual_transports?

Viktor Dukhovni
In reply to this post by B. Reino

> On Sep 4, 2018, at 12:42 PM, B. Reino <[hidden email]> wrote:
>
> I believe the correct way to do this is defining the default virtual transport with
> virtual_transport = lmtp:unix:private/dovecot-lmtp
>
> and then:
> transport_maps = hash:/etc/postfix/virtual_transport
>
> having in /etc/postfix/virtual_transport
> external.domain lmtp:[hostname]:port
>
> Q1) does the above make sense? i.e. will it work as intended (as explained above), ...

In short, yes.  Works as documented.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: multiple/simultaneous virtual_transports?

B. Reino
In reply to this post by Noel Jones-2
On Tue, 4 Sep 2018, Noel Jones wrote:

> To override the transport for a single recipient, use a
> transport_maps entry with the recipient address as the key. No
> change needed for the existing virtual_transport.
>
> something like:
> # /path/to/transport_file
> [hidden email]  lmtp:[someotherhost]:port
>
> # main.cf
> transport_maps = hash:/path/to/transport_file
>

OK! Thanks for the confirmation :)

> ===
>
> Delivering one mail to multiple servers is more complicated.  Add a
> virtual_alias_maps entry to add a second recipient for the message,
> then deliver the second recipient to the alternate server.  If
> necessary, you can use lmtp_generic_maps to rewrite the recipient
> back to the original name during delivery.
>
> # virtual_alias
> [hidden email]   [hidden email]  [hidden email]
>
> # transport
> [hidden email]  lmtp:[other.example.com]:port
>
> # lmtp_generic
> other.example.com  example.com
>
> # main.cf
> virtual_alias_maps = hash:/path/to/virtual_alias
> transport_maps = hash:/path/to/transport
> lmtp_generic_maps = hash:/path/to/lmtp_generic

Double thanks for this!

I still need to clarify what to do with that domain (I host it for a
friend, but I'd rather he keeps his own IMAP server/storage while I take
care of incoming/outgoing e-mails (postfix)).

The multiple delivery would allow me to verify that his own IMAP server
(which still needs to be prepared) receives and serves the e-mails
correctly. Then I'd "pull the plug" and switch to the first option
described above (delivering directly, and only, to his own IMAP server).

Thanks again! (to Viktor too for confirming!)