Following up on my own question – I modified my approach to look like
this:

==================================================
# /usr/local/etc/mail/forwards
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected],[email protected]

# /usr/local/etc/mail/virtuals
[email protected] vmail

# /usr/local/etc/mail/smtpd.conf
table forwards file:/usr/local/etc/mail/forwards
table virtuals file:/usr/local/etc/mail/virtuals

action "expand_forwards" expand-only virtual <forwards>
action "local_mail" lmtp "/var/run/dovecot/lmtp" rcpt-to virtual <virtuals>
action "outbound" relay srs helo mail.example.com

match from any for rcpt-to <forwards> action "expand_forwards"
match from any for rcpt-to <virtuals> action "local_mail"
match for local action "local_mail"

match from any auth for any action "outbound"
match for any action "outbound"
==================================================

This seems to work quite well, with mixed destinations being split via
the "expand_forwards" action, and handled separately by either
"local_mail" or "outbound".

I am grateful for any confirmation that this is the right way to do it
and/or pointers to downsides of this setup.

Thanks!

- Jan

On 2026-01-03 05:32, Jan Eden wrote:

> Hi,
> 
> I am new to OpenSMTPD (having used Postfix so far), and am unsure about
> the handling of mixed destination addresses in virtual tables. In
> Postfix, I had configured something like this:
> 
> ==================================================
> /etc/postfix/virtual
> [email protected] [email protected]
> [email protected] [email protected], [email protected]
> [email protected] [email protected]
> 
> /etc/postfix/mailbox_users
> [email protected] OK
> ==================================================
> 
> Mails to "[email protected]" are delivered via Dovecot (lmtp), while
> external addresses are handled by Postfix. 
> 
> Instead of the virtual mailbox user, I understand that I need to specify
> the Dovecot system user (vmail) directly when combining Dovecot with
> OpenSMTPD:
> 
> ==================================================
> /usr/local/etc/mail/virtuals
> [email protected] vmail
> [email protected] vmail, [email protected]
> [email protected] [email protected]
> ==================================================
> 
> Now my question is – what happens to messages for external destinations
> in the following setup:
> 
> ==================================================
> /usr/local/etc/mail/smtpd.conf
> table virtuals file:/usr/local/etc/mail/virtuals
> 
> [...]
> 
> action "local_mail" lmtp "/var/run/dovecot/lmtp" rcpt-to virtual <virtuals>
> action "outbound" relay helo mail.example.com
> 
> match from any for domain example.com action "local_mail"
> match for local action "local_mail"
> 
> match from any auth for any action "outbound"
> match for any action "outbound"
> 
> ==================================================
> 
> When a message to [email protected] or
> [email protected] arrives, will the expansion through the
> <virtuals> table insert the resulting message into the cycle again, and
> if so, will the last rule match (i.e. will the message be considered as
> coming "from local")? If the message is relayed directly instead, how can
> I specify additional parameters (e.g. the helo hostname, as in the
> "outbound" action)?
> 
> My second question is related to SRS. I did not see the srs option
> specified explicitly in any example configuration, although it is
> required in any forwarding scenario (like the one outlined above) – will
> srs be used implicitly by default, and how do I specify which domains
> are exempt from srs? I use PostSRSd with Postfix, and have to define an
> SRS_DOMAIN as well as SRS_EXLUDE_DOMAINS.
> 
> - Jan
> 

Reply via email to