Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
That would work if users only had one alias, but they don't - they have several aliases.
On my system i am using virtual accounts in postfix with virtual_mailbox_maps. For user alias im using postfix virtual_alias_maps.
user@example.com is a mailbox someone can login to IMAP with. They have alias@example.com -> user@example.com with the alias map.
If someone sends an email to alias@example.com it ends up in the user@example.com inbox via LMTP
Jun 10 13:38:23 postfix/lmtp[1953783]: 4QdlXt4pn1z7Vv0h: to=<user@example.com>, orig_to=<alias@example.com>, relay=smtp.example.com[private/dovecot-lmtp], delay=2.1, delays=1.7/0.01/0/0.44, dsn=2.0.0, status=sent (250 2.0.0 <user@example.com> N9ypKw61hGTzxB0AbpFOwA Saved)
For sieve plugin i have in dovecot.conf:
sieve_vacation_use_original_recipient = no sieve_vacation_dont_check_recipient = no sieve_vacation_send_from_recipient = no sieve_redirect_envelope_from = sender sieve_user_email = %u
And as a sieve rule i have:
require ["vacation"]; # rule:[Out of Office] if true { vacation :days 1 :addresses ["user@example.com","alias@example.com"] :subject "TEST - Out of Office" "This is a test reply for the out of office auto responder."; }
This works for me. If someone sends an email to alias@example.com they will receive an auto reply with the From: header as alias@example.com and the envelope-from as <> which end users wont see.