php邮件的收
php邮件读取:
程序开发的思路:mail文件:先连接到pop3,读取用户的邮件列表,判断邮件是否读取过,如果没读取过就把邮件加到中转的数据库中。get_mail()函数,读取数据库中的邮件列表,读完后对数据库进行清除。以便能一直读取的都是新的邮件。
代码程序:mail文件:
header("content-type:text/html; charset=utf-8");
include 'config.php';
include 'Pop3.php';
include 'mail_config.php';
$conn=mysql_connect($db_host,$db_user,$db_pass);
mysql_query("set names utf8");
mysql_select_db("$mail_data",$conn);
$pop3=new Net_POP3();
if ($pop3->connect($host,110)=="true"){
$bool=$pop3->login($user,$password);
if ($bool=="ture"){
$list=$pop3->_cmdList();
$sum=$pop3->_cmdStat();
echo "<br>";
for ($j=0;$j<$sum[0];$j++){
$head=$pop3->getParsedHeaders($list[$j]['msg_id']);
preg_match("/([a-z0-9A-Z\s]+):([0-9]+):([0-9]+)/",$head['Date'],$rt);
echo "<br>";
$int_time=strtotime($rt[0]);//时间戳
$from=(imap_mime_header_decode($head['from']));
$string='';
for ($i=0;$i<count($from);$i++){
$string="$string".$from[$i]->text;
}
preg_match("/([a-z0-9A-Z_]+)@([a-z0-9A-Z\.]+).([a-z0-9A-Z]+)/",$string,$rg);
$subject=imap_mime_header_decode($head['Subject']);
$title='';
for ($i=0;$i<count($subject);$i++){
$title="$title".$subject[$i]->text;
}
$title=iconv("GB2312","UTF-8",$title);
//判断邮件是否存在,备份邮件
$sql_time="SELECT * from $mail_table_all WHERE timestamp=$int_time";
mysql_query($sql_time)or die(mysql_error());
if (mysql_affected_rows()==0){
$sql="INSERT
相关文档:
<?php
//作者:梁文平 http://www.tyasp.net
session_start();
if($_SESSION["username"]!="admin")
{
echo("<mce:script type="text/javascript"><!--
alert("操作超时!请重新登陆...");window.location.href="../index.php";
// --></mce:script>");
//header("refresh:0;url=../"); ......
Win2003server 下架设PHPWind产品环境
安装前准备:1、安装好iis6
&nbs ......
define("DB_SERVER","127.0.0.1");
define("DB_PORT",3306);
define("DB_CATALOG","uab");
define("DB_USERID","root");
define("DB_PASSWORD","");
$dsn="mysql:host=".DB_SERVER.";port=".DB_PORT.";dbname=".DB_CATALOG;
self::$__PDO=new PDO($dsn, DB_USERID, DB_PASSWORD);
//support long connection
self:: ......