Postfix Email Forwarding: How to Automatically CC All Incoming Messages to Another Address


4 views

When administering mail servers, there are multiple scenarios where you might want to automatically forward copies of incoming emails:

  • Backup and archiving purposes
  • Team collaboration where multiple members need visibility
  • Monitoring and auditing requirements
  • Disaster recovery preparations

The most reliable method is using Postfix's always_bcc feature, which silently sends a copy of every incoming message to a specified address without modifying the original message headers.

Here's how to implement it:

# In /etc/postfix/main.cf
always_bcc = backup@yourdomain.com

# After making changes, reload postfix
sudo postfix reload

For more granular control, virtual aliases can forward specific addresses while maintaining the original recipient information.

# In /etc/postfix/virtual
original@yourdomain.com   original@yourdomain.com backup@yourdomain.com
*@yourdomain.com          original@yourdomain.com backup@yourdomain.com

# Then compile the map and reload
sudo postmap /etc/postfix/virtual
sudo postfix reload

When implementing email forwarding, be aware that:

  • The always_bcc method doesn't modify headers
  • Virtual aliases will show the original recipient in Delivered-To headers
  • Both methods preserve the original sender information

For more complex scenarios, you can integrate Sieve filters with Postfix:

require ["copy", "imap4flags"];

if true {
    redirect :copy "backup@yourdomain.com";
}

Remember that:

  • Each copied message increases server load
  • Disk space usage will grow faster
  • Log files should be monitored for forwarding errors
  • Consider rate limiting if forwarding large volumes

When managing mail servers, there are legitimate cases where you need to automatically forward or CC all incoming emails from one account to another address. Postfix offers several robust methods to accomplish this.

The simplest approach is creating a .forward file in the user's home directory:

# Create the file
touch /home/username/.forward

# Add destination email
echo "destination@example.com" > /home/username/.forward

# Set proper permissions
chmod 644 /home/username/.forward
chown username:username /home/username/.forward

This method keeps the original recipient in the delivery chain while sending a copy to the specified address.

For system-wide forwarding, modify /etc/postfix/virtual:

# Add this line to /etc/postfix/virtual
source@yourdomain.com  destination@example.com

Then update Postfix configuration and maps:

postmap /etc/postfix/virtual
postfix reload

For more advanced scenarios where you need to BCC all emails, edit main.cf:

# Add to /etc/postfix/main.cf
always_bcc = destination@example.com

This will secretly copy all outgoing AND incoming emails for the entire server.

For selective forwarding based on patterns, use header_checks:

# In /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks

# In /etc/postfix/header_checks
/^To:.*@source-domain.com/ REDIRECT destination@example.com

When implementing these solutions:

  • Monitor disk I/O for high-traffic mail servers
  • Consider using separate queues for forwarded mail
  • Implement rate limiting if forwarding to external domains