只是说...我不知道我该怎么做:).
换句话说,问题是:你收到一些来自pinky@pinky.com的邮件,你用自己的内容回复,而pinky@pinky.com将你的回复存储在他的数据库中.
附加:我使用共享主机,我在PHP中编码,我了解ASP.如果你知道如何用另一种语言编写这个脚本,不要费心解释我,因为我什么都不懂.
还欢迎提供解决方案的链接.
提前致谢.
小智 7
所以
- 你有一个服务器
- 你收到电子邮件
- 你想将它们保存在一个mysql数据库中
Cpanel配置
- 转到cpnal电子邮件转发器
- 添加一个新的
- 重定向到PATH - > /home/your_user/whatever/php.script.php
PHP脚本 (您可能需要根据您的服务器配置更改"/ usr/bin/php -q"路径)
#!/usr/bin/php -q
<?php
chdir(dirname(__FILE__));
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
if(strlen($email)<1) {
die();
}
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$to="";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for ($i=0; $i < count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
if (preg_match("/^To: (.*)/", $lines[$i], $matches)) {
$to = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
Run Code Online (Sandbox Code Playgroud)
适用于共享主机!:)
你需要添加的是mysql插入并使用上面定义的变量.你知道怎么用php的mysql数据库吗?或者你也需要帮助吗?
| 归档时间: |
|
| 查看次数: |
30356 次 |
| 最近记录: |