我试图设置一个程序来接受传入的电子邮件,然后将“发件人”和“消息”分解为 php 变量,然后我可以根据需要进行操作,但我不确定从哪里开始。
我已经将电子邮件地址通过管道传输到相关的 php 文件(通过 cpanel)
最佳答案
开始于:
$lines = explode("\n",$message_data);
$headers = array();
$body = '';
$in_body = false;
foreach($lines as $line)
{
if($in_body)
{
$body .= $line;
}
elseif($line == '')
{
$in_body = true;
}
else
{
list($header_name,$header_value) = explode(':',$line,2);
$headers[$header_name] = $header_body;
}
}
// now $headers is an array of all headers and you could get the from address via $headers['From']
// $body contains just the body
我只是在脑海中写下了这些;尚未测试语法或错误。只是一个起点。
关于PHP电子邮件管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1219790/