smtp邮件发送一例

雪化了1977

雪化了1977

2016-01-29 14:19

smtp邮件发送一例,smtp邮件发送一例
  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
展开更多 50%)
分享

猜你喜欢

smtp邮件发送一例

PHP
smtp邮件发送一例

pop3邮件收取一例

PHP
pop3邮件收取一例

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

SMTP协议-PHP的邮件发送程序例子

Web开发
SMTP协议-PHP的邮件发送程序例子

用c#写的smtp邮件发送类

电脑网络
用c#写的smtp邮件发送类

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

使用PHP通过SMTP发送邮件新手指南

PHP
使用PHP通过SMTP发送邮件新手指南

实现FTP访问一例

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
实现FTP访问一例

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

《龙之守护》攻略之金币获取途径解析

《龙之守护》攻略之金币获取途径解析

MySQL通用查询程序

MySQL通用查询程序
下拉加载更多内容 ↓