Rewrite recipient of all (except one recipient) outgoing e-mail
I'd like to share some configuration which works in my use case (deliver all messages to my local mailbox regardless of recipient entered).
Running Ubuntu 14.04, postfix version 2.11.0
Add the following lines to
/etc/postfix/main.cf
sender_canonical_maps = regexp:/etc/postfix/sender_canonical recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical transport_maps = hash:/etc/postfix/transport
Create
/etc/postfix/transport
with content* : yoshi
Create
/etc/postfix/sender_canonical
/.+/ [email protected]
Create
etc/postfix/recipient_canonical/
/.+/ [email protected]
Update configuration:
sudo postmap /etc/postfix/transport sudo postmap /etc/postfix/recipient_canonical sudo postmap /etc/postfix/sender_canonical
Restart postfix:
sudo service postfix restart
Now if I run for example the following script:
<?php
mail("[email protected]", "PseudoFaullt to local Inbox", "This is a manual scam mail, please steal money from yourself.\nThank you for the cooperation");
I receive it with a rewritten recipient in my local inbox. Actually I'm not sure if you need the sender and transport configuration but I had the impression it wasn't working without. So you might want to give it a shot to shorten the process.
Watch out the *_maps*
directives in /etc/postfix/main.cf
are prefixed with regexp:
rather than hash:
.
So for your single exception maybe a witty regular expression will do the job.
Very detailed answer about setting up postfix, local inboxes and how to access them with Thunderbird:
https://askubuntu.com/a/209877
Information about sender_canonincal_maps
:
http://binblog.info/2012/09/27/postfix-rewrite-the-sender-address-of-all-outgoing-mail/