-1

I'm trying to get Postfix to pipe ALL email coming in on a specific domain to a PHP script. So far I've been able to do this via a tutorial I found on the web and also editing the /etc/postfix/virtual file with something like what's below;

@domain.com root

The problem is that Postfix is re-writing the original recipient email address (for example [email protected]) to [email protected] and the PHP script receiving the email does not get the original recipient ([email protected]). It is important that the PHP script sees [email protected] instead of [email protected].

Is it possible for Postfix to direct all incoming mail to the PHP script without modifying the address like in the example above?

Note: There can/will potentially be 10,000's of incoming email addresses.

Any ideas on how I can get Postfix to do what I want?

1
  • Got this working but haven't a clue how I did so. I will need to rebuild the server again in a couple of weeks time. Once I do I will post the steps here. Aug 11, 2014 at 2:25

1 Answer 1

1

You could set an additional header via Postfix:

create a /etc/postfix/appendheader.regexp:

/(.+)/ PREPEND X-Original-To: $1

in /etc/postfix/main.cf:

smtpd_data_restrictions = pcre:/etc/postfix/append_header.regexp

This will add an X-Original-To:-header with the original mail address before it's getting rewritten. Have your PHP-Script parse this header instead of the To:-Header.

3
  • Postfix already does this, which is the behavior he's complaining about. Aug 8, 2014 at 13:20
  • Where exactly is he complaining about getting an X-Original-To:-header?
    – etagenklo
    Aug 8, 2014 at 13:28
  • Unfortunately this cannot work because I want this file to later be indexed by a third party app. Letting Postfix rewrite the address will mean that the third party app will ultimately read the value in the "To" field as [email protected] and index the document incorrectly. Aug 8, 2014 at 21:03

Not the answer you're looking for? Browse other questions tagged .