简体   繁体   English

电子邮件应用程序帮助。 将电子邮件发送到组成的电子邮件地址,该地址将重定向到真实电子邮件

[英]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". 用户注册,并说用户名“ johny-jones”。
  • Lets say for example that my domain is www.example.com 例如,假设我的域名是www.example.com
  • if anyone emails johny-jones@example.com this email is redirected to johny-jones REAL email address 如果有人通过电子邮件发送johny-jones@example.com,则此电子邮件将重定向到johny-jones REAL电子邮件地址

The simplest option is to tell your smtp server to forward all ingoing mails to an external program (your php script). 最简单的选择是告诉您的smtp服务器将所有传入的邮件转发到外部程序(您的php脚本)。 For example, for qmail this will be like | php myphpscript.php 例如,对于qmail,它将类似于| php myphpscript.php | php myphpscript.php in .qmail file. .qmail文件中的| php myphpscript.php 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. 您基本上是在描述邮件传输代理 AKA邮件服务器。 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. 因此,您所要做的就是在其上运行服务器,所需的MX DNS记录以及一个API,该API允许您配置转发地址。 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: 只需将所有孤儿电子邮件(特定于该域)传送到您的PHP脚本,然后使用类似以下的方法提取电子邮件内容:

$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. 然后提取“收件人”字段,如果它属于用户,则将电子邮件转发给他。如果您拥有cPanel ..,这甚至更容易。 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 goto邮件>默认地址>设置默认地址,而不是在其中放置电子邮件地址,而不是在其中添加诸如"|php -q /home/whatever/public_html/pipe.php"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM