LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Postfix special virtual domain (https://www.linuxquestions.org/questions/linux-server-73/postfix-special-virtual-domain-592765/)

dlublink 10-18-2007 10:02 AM

Postfix special virtual domain
 
Hello,

I have a special virtual domain my postfix which is @special.mydomain.tld.

I would like any emails to that address to be sent to a command and as the first parameter of the email have the username from before @special or the entire username@special.mydomain.tld.

Trouble is this:

I setup in virtual like so:

@special.mydomain.tld : special@mydomain.tld

and in alias

special@mydomain.tld | /etc/postfix/mycommand

trouble is, the only way to recover is with the X-Original-To: header in the email, but it is not always correct.

Because I also have an alias on my server that points to a mailbox and an email on special@mydomain.tld, so when emails from from here X-Original-To contains the first email and not the email for special@mydomain.tld, so I am screwed.

Possibilities:

1. Execute the command directly from a virtual alias ( I can't figure out how to do this )
2. Perhaps something in master.cf could be configured for this? Use transport to deliver it?
3. ... other ideas?

Any ideas what to do or how to do one of the ideas I suggested?

edit:
I have done a bit of research and it would seem that having the code in master.cf is the best way to handle this. What I need to figure out is how to tell the virtual delivery to deliver @special.domain.tld to special in master and everything else to virtual as it does by default.


Thanks,

David

dlublink 10-18-2007 10:40 AM

Problem solved, in master.cf I added:

special unix - n n - - pipe
flags=DRhu user=nobody argv=/etc/postfix/special ${recipient}

In /etc/postfix/transport I added:

special.lublink.net special

I ran postmap transport ( from the /etc/postfix directory)

In /etc/postfix/special (which is a php script ) :

#!/usr/bin/php
<?


$email = file_get_contents('php://stdin');

$destination = $argv[1];

// do something here.

?>

dlublink 10-18-2007 01:12 PM

IMPORTANT NOTE!!!!

My server was rejecting emails to the domain listed, turns out that I need to have an account for each email address I want to accept on the domain. In my case I used a catch all since the domain is well hidden.

This is because postfix checks for the existance of the virtual domain, than the user (or domain catch all) than it delivers the message.

David

dlublink 10-18-2007 01:16 PM

There is some related discussion here: http://www.linuxquestions.org/questi...=1#post2928716


All times are GMT -5. The time now is 06:45 AM.