日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 使用postfix发邮件,PHP处理postfix邮件内容的方法

發布時間:2024/10/12 php 74 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 使用postfix发邮件,PHP处理postfix邮件内容的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文實例講述了PHP處理postfix郵件內容的方法。分享給大家供大家參考。具體如下:

//從輸入讀取到所有的郵件內容

$email = "";

$fd = fopen("php://stdin", "r");

while (!feof($fd)) {

$email .= fread($fd, 1024);

}

fclose($fd);

//記錄所有的內容,測試

file_put_contents("/tmp/mail/".time(), $email);

//處理郵件

$lines = explode("\n", $email);

// empty vars

$from = "";

$date = "";

$subject = "";

$message = "";

$splittingheaders = true;

for ($i=0; $i

if ($splittingheaders) {

// look out for special headers

if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {

$subject = $matches[1];

}

if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {

if(strpos($lines[$i],"

//the name exist too in from header

$data = explode(‘

$from = substr(trim($data[1]),0,-1);

}else{

//only the mail

$from = $matches[1];

}

}

if (preg_match("/^Date: (.*)/", $lines[$i], $matches)) {

$date = $matches[1];

}

} else {

// not a header, but message

$message .= $lines[$i]."\n";

}

if (trim($lines[$i])=="") {

// empty line, header section has ended

$splittingheaders = false;

}

}

$when = date("Y-m-d G:i:s");

$data = explode([email?protected],$from);

$username = $data[0];

//記錄到數據庫

$sql = "insert into mails ( `username`, `from`, `subject`, `date`, `message`) values ( ‘$username‘, ‘$from‘, ‘$subject‘, ‘$when‘, ‘$message‘)";

//測試

file_put_contents("/tmp/mail2.log", $sql);

?>

希望本文所述對大家的php程序設計有所幫助。

原文:http://www.jb51.net/article/67969.htm

總結

以上是生活随笔為你收集整理的php 使用postfix发邮件,PHP处理postfix邮件内容的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。