当前位置: 网学 > 编程文档 > PHP > 正文

POP3、SMTP邮件收发程序

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式

<?php
if ($EMAIL_INC) return;
$EMAIL_INC= "defined";
define( "SmtpPort",25);

class Pop3 {
var $subject; // 邮件主题
var $from_email; // 发件人地址
var $from_name; // 发件人姓名
var $to_email; // 收件人地址
var $to_name; // 收件人姓名
var $body; // 邮件内容
var $filename; // 文件名
var $socket; // 当前的 socket
var $Line;
var $Status;

function pop3_open($server, $port)
{

$this->Socket = fsockopen($server, $port);
if ($this->Socket <= 0){
return false;
}
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return false;
return true;
}

function pop3_user($user)
{

if ($this->Socket < 0){
return false;
}
fputs($this->Socket, "USER $this->userrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return false;

return true;
}

function pop3_pass( $pass)
{

fputs($this->Socket, "PASS $passrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return 0;

return 1;
}

function pop3_stat()
{

fputs($this->Socket, "STATrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return 0;

if (!eregi( "+OK (.*) (.*)", $this->Line, $regs))
return 0;

return $regs;
}

function pop3_list()
{
fputs($this->Socket, "LISTrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return 0;

$i = 0;
while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".")
{
$articles[$i] = $this->Line;
$i++;
}
$articles[ "count"] = $i;

return $articles;
}

function pop3_retr($nr)
{

fputs($this->Socket, "RETR $nrrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status[ "LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status[ "LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status[ "LASTRESULT"] <> "+") return 0;

while (substr($this->Line =
  • 上一篇资讯: Php调用Unix/Linux命令举例
  • 下一篇资讯: PHP实现文件下载
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号