Dovecot - configuring auto forward sender address

Configuring auto forward sender address

Configuring autoforward sender address — Dovecot documentation

Solution:

Sieve needs to have

plugin {
  # Use editheader
  sieve_extensions = +editheader
}

The following is an example of what the Sieve rules could look like:

require "editheader";
require "variables";
require "envelope";

# ... Any other rules

# Obtain the user's full email address somehow
# It can be obtained from the recipient address (without full name)
# An alternative is to put the primary address into the script as a literal.
if envelope :matches "to" "*" { set "user_email" "${1}"; }

# This part of the script MUST be the final rule, otherwise other rules are
# affected since the message is modified.

# Drop the original "From:" header
deleteheader "from";

# Add a new "From:" header
addheader "From" "${user_email}";