smtp邮件发送一例

2016-01-29 14:19 13 1 收藏

smtp邮件发送一例,smtp邮件发送一例

【 tulaoshi.com - PHP 】

  test_smtp.php

<?
require("smtp.php");

$smtp=new smtp_class;

$smtp-host_name="mail.xiaocui.com";
$smtp-localhost="localhost";
$from="webmaster@xiaocui.com";
$to="root@xiaocui.com";
if($smtp-SendMessage(
  $from,
  array(
   $to
  ),
  array(
   "From: $from",
   "To: $to",
   "Subject: Testing Manuel Lemos' SMTP class"
  ),
  "Hello $to,nnIt is just to let you know that your SMTP class is working just fine.nnBye.n"))
  echo "Message sent to $to OK.n";
else
  echo "Cound not send the message to $to.nError: ".$smtp-error."n"
?

smtp.php

<?

class smtp_class
{
var $host_name="";
var $host_port=25;
var $localhost="";
var $timeout=0;
var $error="";
var $debug=1;
var $esmtp=1;
var $esmtp_host="";
var $esmtp_extensions=array();
var $maximum_piped_recipients=100;

/* private variables - DO NOT ACCESS */

var $state="Disconnected";
var $connection=0;
var $pending_recipients=0;

/* Private methods - DO NOT CALL */

Function OutputDebug($message)
{
  echo $message,"<brn";
}

Function GetLine()
{
  for($line="";;)
  {
   if(feof($this-connection))
   {
    $this-error="reached the end of stream while reading from socket";
    return(0);
   }
   if(($data=fgets($this-connection,100))==false)
   {
    $this-error="it was not possible to read line from socket";
    return(0);
   }
   $line.=$data;
   $length=strlen($line);
   if($length=2
   && substr($line,$length-2,2)=="rn")
   {
    $line=substr($line,0,$length-2);
    if($this-debug)
     $this-OutputDebug("< $line");
    return($line);
   }
  }
}

Function PutLine($line)
{
  if($this-debug)
   $this-OutputDebug(" $line");
  if(!fputs($this-connection,"$linern"))
  {
   $this-error="it was not possible to write line to socket";
   return(0);
  }
  return(1);
}

Function PutData($data)
{
  if(strlen($data))
  {
   if($this-debug)
    $this-OutputDebug(" $data");
   if(!fputs($this-connection,$data))
   {
    $this-error="it was not possible to write data to socket";
    return(0);
   }
  }
  return(1);
}

Function VerifyResultLines($code,$responses="")
{
  if(GetType($responses)!="array")
   $responses=array();
  Unset($match_code);

  while(($line=$this-GetLine($this-connection)))
  {
   if(IsSet($match_code))
   {
    if(strcmp(strtok($line," -"),$match_code))
    {
     $this-error=$line;
     return(0);
   &nbs

来源:https://www.tulaoshi.com/n/20160129/1493005.html

延伸阅读
标签: autocad教程
本文由 wzm1234568 原创,转载请保留此信息! Tulaoshi.Com 昨天把平面图练习集(进阶型)140P做完了。在做的过程中,127题始终没有做出来。郁闷了好久。昨天终于找到答案了。我现在把做的过程贴出来。呵呵。(我可是初学者哟,高手看后要扔砖头的,捡小一点的啊,谢谢!!!) (另外,说一下,这个做法是我请教的高手教的,不...
这是一个时钟程序,使我刚学完Turbo C作图后写的。程序原理我不再说明,在程序中有具体的注释。程序不足之处,请各位多多指点。/**********************************************               Clock.c          &nbs...
标签: PS PS教程
本教程为 www.jcwcn.com 中国 叶冷原创,如转载请保留这段话: 关于黑色背景抠发,感到困惑的人还是比较多,今天来发个有关这样的抠发帖子。 先贴原图 screen.width-500)this.style.width=screen.width-500;" border=0 pop="按此在新窗口浏览图片"> 下面的两个图,其中左图是原图,右图是用原图复制一个图层后将图层模式设定为“屏幕”后的...
  通过代码优化,可以提高代码的执行效率,从而提升程序的品质。因而优化代码是程序员提高自身水平,提高技能的一个很重要途径。不同的代码有不同的分析方法,有不同的优化方法,而这全凭程序员的经验积累和自身水平。在公司里我既担任项目经理,也担任系统分析员,因而经常需要帮助程序员优化代码,因而在工作中积累了一些经验。为了将这...
HTTP协议在浏览器中使用的原理:首先,Web浏览器与服务器建立连接,然后Web浏览器通过HTTP协议向服务器请求文档,最后,由服务器向Web浏览器应答,关闭连接。这就是HTTP协议的一般工作过程。下面,使用VisualBasic5.0中文版来实现一个简单的Web服务器,使用Tcp/IP协议的80端口,一般浏览器中的Http协议默认此端口,然后设置好超文本文件的发布路...

经验教程

579

收藏

23
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部