8

how to send a copy to another email address of all incoming messages from an email account?(postfix)

it's possible?

thx.

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
Mrsksdk
  • 89
  • 1
  • 1
  • 2

4 Answers4

15

You can simply use recipient_bcc_maps to copy all emails being sent to a specific user (or a specific domain).

For example add the following line to your main.cf (or use postconf for that):

recipient_bcc_maps = hash:/etc/postfix/recipient_bcc_maps

and create a file /etc/postfix/recipient_bcc_maps with the following content:

user@example.com  recipient@example.net

and run postmap recipient_bcc_maps.

joschi
  • 21,387
  • 3
  • 47
  • 50
  • And don't forget to issue 'service reload postfix' or 'systemctl reload postfix', whether your distro uses systemd or not. Otherwise postfix will not use the newly postmapped file – user2965433 Dec 01 '21 at 09:39
6

You can do this by creating two aliases for the account, as follows:

Let's say you have two email addresses: mom@example.com and kid@example.com, and you want mom to get a copy of all of kid's email. In this case, mom@example.com and kid@example.com would both be accounts, but you would also create the following aliases:

From:                         To:
kid@example.com               mom@example.com
kid@example.com               kid@example.com

Postfix will understand this -- the kid -> kid alias does not create a loop (though it looks like it should!), instead it tells Postfix to continue on to delivering to the mailbox even though the mail was already delivered to the alias.

HedgeMage
  • 523
  • 3
  • 9
1

one solution is to use procmail a different solution is to use ~/.forward file. over the two procmail has far more options and control.

silviud
  • 2,687
  • 2
  • 18
  • 19
1

I suggest using this milter if your postfix storage format is mbox: http://www.dancingfortune.com/projects/archivesmtp/index.php

the advantage is that if a user is authenticated and not using the proper from details his mail will still be caught by this milter while the sender_bcc_maps won't catch it.