views:

99

answers:

3

I'm wondering how i would go about making the following application:

  • a user signs up, say with the username "johny-jones".
  • Lets say for example that my domain is www.example.com
  • if anyone emails [email protected] this email is redirected to johny-jones REAL email address
+1  A: 

The simplest option is to tell your smtp server to forward all ingoing mails to an external program (your php script). For example, for qmail this will be like | php myphpscript.php in .qmail file. Your script will read email from stdin and resend it to the real address.

stereofrog
A: 

You're basically describing a mail transfer agent AKA mail server. So all you need to do is a server to run it on, the required MX DNS records, and an API that allows you to configure forward addresses. Look through the documentation of the servers listed here to see which ones offer the latter.

Michael Borgwardt
A: 

as stereofrog has already mentioned .. just pipe all orphan email (specific to that domain) to ur PHP script and use something like this to extract the email content:

$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
    $email .= fread($fd, 1024);
}
fclose($fd);

then extract the "to" field and if it belongs to a user .. forward the email to him.If you have cPanel .. this is even easier. goto mail > default address > set default address and instead of putting an email address there put something like this "|php -q /home/whatever/public_html/pipe.php" .. ofcourse without the quotes

Sabeen Malik