开发者

email application help. Send email to made up email address which is redirected to real email

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 johny-jones@example.com thi开发者_JAVA百科s email is redirected to johny-jones REAL email address


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜