利用php mail 发送邮件代码

 更新时间:2016年11月25日 17:01  点击:1471

本款php发送邮件代码他利用了php自由的邮件发送函数mail进行邮件发送的,他会利用二种试一是判断mail函数是否可用,如果行就利用它来发送否则fsockopen来操作。
*/

 代码如下 复制代码

class email
{
 function email()
 {
  $this->__construct();
 }

 function __construct()
    {
  @define('charset','gbk');
  $this->set(mail_server, mail_port, mail_user, mail_pwd,mail_type);
  $this->auth = 1;
 }

 function set($server, $port, $user, $password, $type = 1, $delimiter = 1, $mailusername = 0)
 {
  $this->type = $type;
  $this->server = $server;
  $this->port = $port;
  $this->user = $user;
  $this->password = $password;
        $this->delimiter = $delimiter == 1 ? "rn" : ($delimiter == 2 ? "r" : "n");
  $this->mailusername = $mailusername;
 }
 
 function send($email_to, $email_subject, $email_message, $email_from = '')
 {
  global $dircms;
  $email_to=iconv("utf-8", "gbk", $email_to);
  $email_subject=iconv("utf-8", "gbk", $email_subject);
  $email_message=iconv("utf-8", "gbk", $email_message);
  $email_subject = '=?'.charset.'?b?'.base64_encode(str_replace("r", '', $email_subject)).'?=';
  $email_message = str_replace("rn.", " rn..", str_replace("n", "rn", str_replace("r", "n", str_replace("rn", "n", str_replace("nr", "r", $email_message)))));
  $adminemail = $this->type == 1 ? $dircms['mail_user'] : $dircms['mail_user'];
  $email_from = $email_from == '' ? '=?'.charset.'?b?'.base64_encode($dircms['site_name'])."?= <$adminemail>" : (preg_match('/^(.+?) <(.+?)>$/',$email_from, $from) ? '=?'.charset.'?b?'.base64_encode($from[1])."?= <$from[2]>" : $email_from);
  $emails = explode(',', $email_to);
  foreach($emails as $touser)
  {
   $tousers[] = preg_match('/^(.+?) <(.+?)>$/',$touser, $to) ? ($this->mailusername ? '=?'.charset.'?b?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;
  }
  $email_to = implode(',', $tousers);
  $headers = "from: $email_from{$this->delimiter}x-priority: 3{$this->delimiter}x-mailer: dircms {$this->delimiter}mime-version: 1.0{$this->delimiter}content-type: text/html; charset=".charset."{$this->delimiter}";
  if($this->type == 1)
  {
   return $this->smtp($email_to, $email_subject, $email_message, $email_from, $headers);
  }
  elseif($this->type == 2)
  {
   return @mail($email_to, $email_subject, $email_message, $headers);
  }
  else
  {
   ini_set('smtp', $this->server);
   ini_set('smtp_port', $this->port);
   ini_set('sendmail_from', $email_from);
   return @mail($email_to, $email_subject, $email_message, $headers);
  }
 }

 function smtp($email_to, $email_subject, $email_message, $email_from = '', $headers = '')
 {
  global $dircms;
  if(!$fp = fsockopen($this->server, $this->port, $errno, $errstr, 10))
  {
   $this->errorlog('smtp', "($this->server:$this->port) connect - unable to connect to the smtp server", 0);
   return false;
  }
  stream_set_blocking($fp, true);
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != '220')
  {
   $this->errorlog('smtp', "$this->server:$this->port connect - $lastmessage", 0);
   return false;
  }
  fputs($fp, "ehlo dircmsrn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250)
  {
   $this->errorlog('smtp', "($this->server:$this->port) helo/ehlo - $lastmessage", 0);
   return false;
  }
  while(1)
  {
   if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage))
   {
    break;
   }
   $lastmessage = fgets($fp, 512);
  }
  fputs($fp, "auth loginrn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 334)
  {
   $this->errorlog('smtp', "($this->server:$this->port) auth login - $lastmessage", 0);
   return false;
  }
  fputs($fp, base64_encode($this->user)."rn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 334)
  {
   $this->errorlog('smtp', "($this->server:$this->port) username - $lastmessage", 0);
   return false;
  }
  fputs($fp, base64_encode($this->password)."rn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 235)
  {
   $this->errorlog('smtp', "($this->server:$this->port) password - $lastmessage", 0);
   return false;
  }
  fputs($fp, "mail from: <".preg_replace("/.*<(.+?)>.*/", "", $email_from).">rn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 250)
  {
   fputs($fp, "mail from: <".preg_replace("/.*<(.+?)>.*/", "", $email_from).">rn");
   $lastmessage = fgets($fp, 512);
   if(substr($lastmessage, 0, 3) != 250)
   {
    $this->errorlog('smtp', "($this->server:$this->port) mail from - $lastmessage", 0);
    return false;
   }
  }
  $email_tos = array();
  $emails = explode(',', $email_to);
  foreach($emails as $touser)
  {
   $touser = trim($touser);
   if($touser)
   {
    fputs($fp, "rcpt to: <".preg_replace("/.*<(.+?)>.*/", "", $touser).">rn");
    $lastmessage = fgets($fp, 512);
    if(substr($lastmessage, 0, 3) != 250)
    {
     fputs($fp, "rcpt to: <".preg_replace("/.*<(.+?)>.*/", "", $touser).">rn");
     $lastmessage = fgets($fp, 512);
     $this->errorlog('smtp', "($this->server:$this->port) rcpt to - $lastmessage", 0);
     return false;
    }
   }
  }
  fputs($fp, "datarn");
  $lastmessage = fgets($fp, 512);
  if(substr($lastmessage, 0, 3) != 354)
  {
   $this->errorlog('smtp', "($this->server:$this->port) data - $lastmessage", 0);
  }
  $headers .= 'message-id: <'.gmdate('ymdhs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_server['http_host'].">{$this->delimiter}";
  fputs($fp, "date: ".gmdate('r')."rn");
  fputs($fp, "to: ".$email_to."rn");
  fputs($fp, "subject: ".$email_subject."rn");
  fputs($fp, $headers."rn");
  fputs($fp, "rnrn");
  fputs($fp, "$email_messagern.rn");
  fputs($fp, "quitrn");
  return true;
 }

 function errorlog($type, $message, $is)
 {
  $this->error[] = array($type, $message, $is);
 }
}

用的mail()函数,感觉不好用,而且感觉这个邮件地址不能太多,一次copy了100个可能会出问题,下面提供一款可以限制发送邮件php类函数。
*/

 代码如下 复制代码

class sendmail{
    function __construct(){
        $this->set();
        $this->auth = 1;
    }

    function set($server=yj_sysmail_smtp,$user="",$password=yj_sysmail_pass,$port=yj_sysmailport,$type=1,$mailusername=0){
        $user=($user=="")?substr(yj_sysmail,0,stripos(yj_sysmail,"@")):$user;

        $this->type = $type;
        $this->server = $server;
        $this->port = $port;
        $this->user = $user;
        $this->password = $password;
        $this->mailusername = $mailusername;
    }

    function send($email_to, $email_subject, $email_message, $email_from = ''){
        $email_subject = '=?utf-8?b?'.base64_encode(str_replace("r", '', $email_subject)).'?=';
        $email_message = str_replace("rn.", " rn..", str_replace("n", "rn", str_replace("r", "n", str_replace("rn", "n", str_replace("nr", "r", $email_message)))));
        $email_from = $email_from == '' ? '=?utf-8?b?'.base64_encode(yj_sysname)."?= <".yj_sysmail.">" : (preg_match('/^(.+?) <(.+?)>$/',$email_from, $from) ? '=?utf-8?b?'.base64_encode($from[1])."?= <$from[2]>" : $email_from);
        $emails = explode(',', $email_to);
        foreach($emails as $touser){
            $tousers[] = preg_match('/^(.+?) <(.+?)>$/',$touser, $to) ? ($this->mailusername ? '=?utf-8?b?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;
        }
        $email_to = implode(',', $tousers);
        $headers = "mime-version: 1.0rnto: {$email_to}rnfrom: {$email_from}<{$email_from}>rnx-priority: 3rnx-mailer: eglive rndate: ".date("r")."rncontent-type: text/html; charset=utf-8rn";

        if($this->type == 1){
            return $this->smtp($email_to, $email_subject, $email_message, $email_from, $headers);
        }elseif($this->type == 2){
            return @mail($email_to, $email_subject, $email_message, $headers);
        }else{
            ini_set('smtp', $this->server);
            ini_set('smtp_port', $this->port);
            ini_set('sendmail_from', $email_from);
            return @mail($email_to, $email_subject, $email_message, $headers);
        }
    }

    function smtp($email_to, $email_subject, $email_message, $email_from = '', $headers = ''){
        if(!$fp = @fsockopen($this->server, $this->port, $errno, $errstr, 10)){
            $this->errorlog('smtp', "($this->server:$this->port) connect - unable to connect to the smtp server", 0);
            return false;
        }
        stream_set_blocking($fp, true);
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != '220'){
            $this->errorlog('smtp', "$this->server:$this->port connect - $lastmessage", 0);
            return false;
        }
        fputs($fp, ($this->auth ? 'ehlo' : 'helo')." phpcmsrn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250){
            $this->errorlog('smtp', "($this->server:$this->port) helo/ehlo - $lastmessage", 0);
            return false;
        }
        while(1){
            if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)){
                break;
            }
            $lastmessage = fgets($fp, 512);
        }
        fputs($fp, "auth loginrn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 334){
            $this->errorlog('smtp', "($this->server:$this->port) auth login - $lastmessage", 0);
            return false;
        }
        fputs($fp, base64_encode($this->user)."rn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 334){
            $this->errorlog('smtp', "($this->server:$this->port) username - $lastmessage", 0);
            return false;
        }
        fputs($fp, base64_encode($this->password)."rn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 235){
            $this->errorlog('smtp', "($this->server:$this->port) password - $lastmessage", 0);
            return false;
        }
        fputs($fp, "mail from: <".preg_replace("/.*<(.+?)>.*/", "", $email_from).">rn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 250){
            fputs($fp, "mail from: <".preg_replace("/.*<(.+?)>.*/", "", $email_from).">rn");
            $lastmessage = fgets($fp, 512);
            if(substr($lastmessage, 0, 3) != 250){
                $this->errorlog('smtp', "($this->server:$this->port) mail from - $lastmessage", 0);
                return false;
            }
        }
        $email_tos = array();
        $emails = explode(',', $email_to);
        foreach($emails as $touser){
            $touser = trim($touser);
            if($touser){
                fputs($fp, "rcpt to: <".preg_replace("/.*<(.+?)>.*/", "", $touser).">rn");
                $lastmessage = fgets($fp, 512);
                if(substr($lastmessage, 0, 3) != 250){
                    fputs($fp, "rcpt to: <".preg_replace("/.*<(.+?)>.*/", "", $touser).">rn");
                    $lastmessage = fgets($fp, 512);
                    $this->errorlog('smtp', "($this->server:$this->port) rcpt to - $lastmessage", 0);
                    return false;
                }
            }
        }
        fputs($fp, "datarn");
        $lastmessage = fgets($fp, 512);
        if(substr($lastmessage, 0, 3) != 354){
            $this->errorlog('smtp', "($this->server:$this->port) data - $lastmessage", 0);
        }
        $headers .= 'message-id: <'.gmdate('ymdhs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_server['http_host'].">rn";
        fputs($fp, "date: ".gmdate('r')."rn");
        fputs($fp, "to: ".$email_to."rn");
        fputs($fp, "subject: ".$email_subject."rn");
        fputs($fp, $headers."rn");
        fputs($fp, "rnrn");
        fputs($fp, "$email_messagern.rn");
        $lastmessage = fgets($fp, 512);
        fputs($fp, "quitrn");
        return true;
    }

    function errorlog($type, $message, $is){
        $this->error[] = array($type, $message, $is);
    }

    function mailmess($mess=""){
        return "<style>*{font-family:verdana;font-size:13px;/*www.111cn.net提供*/}</style>
        <table cellpadding='5' cellspacing='1' border='0' width='750' style='background-color:#fff;border:1px solid #3b5998;padding:15px;'>
        <tr><td style='background:#3b5998;color:#fff;font-weight:bold;font-size:14px;'>".yj_syscnname." - ".yj_sysname."</td></tr>
        <tr><td>{$mess}</td></tr>
      
        </table>";
    }
}

phpmailer是一个用于发送电子邮件的php类,他比php自带的函数mail强多了,phpmailer可以到官方下载。
下面来看一个只发送文本的实例。
*/

 代码如下 复制代码

require("class.phpmailer.php");
$mail = new phpmailer();
$mail->ismail();

$mail->addaddress("email@example.com");
$mail->subject = "test 1";
$mail->body = "test 1 of phpmailer.";

if(!$mail->send())
{
   echo "error sending: " . $mail->errorinfo;;
}
else
{
   echo "letter sent";
}
/*
$mail->ismail();  必须发送

issendmail - via sendmail command.
isqmail - directly via qmail mta.
issmtp - via smtp server.
这里有一个使用smtp样本。我们假设该smtp需要授权。如果in't nessesary,只写$邮件> smtpauth = 0;。要使用的服务器数量使用semicolumn为分隔符
*/

require("class.phpmailer.php");
$mail = new phpmailer();$mail = new phpmailer();
$mail->issmtp();
$mail->host = "smtp1.example.com;smtp2.example.com";
$mail->smtpauth = true;
$mail->username = 'smtpusername';
$mail->password = 'smtppassword';

$mail->addaddress("email@example.com");
$mail->subject = "test 1";
$mail->body = "test 1 of phpmailer.";

if(!$mail->send())
{
   echo "error sending: " . $mail->errorinfo;;
}
else
{
   echo "letter is sent";
}

/*

添加有关发件人inforation,使用以下功能

 代码如下 复制代码

mail->from="mailer@example.com";
$mail->fromname="my site's mailer";
$mail->sender="mailer@example.com"; // indicates returnpath header
$mail->addreplyto("replies@example.com", "replies for my site"); // indicates replyto headers

for specifying various types of recepients use these:

$mail->addaddress("mail1@domain.com", "recepient 1");
$mail->addcc("mail1@domain.com", "recepient 1");
$mail->addbcc("mail1@domain.com", "recepient 1");


如何出现乱码可利用

$mail->charset="windows-1251";
$mail->charset="utf-8";

设置编码


如果要想发送邮件可以发送图片和附低年及html代码就在$mail-send()前面加

 代码如下 复制代码
$mail->ishtml(true);
$mail->addembeddedimage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
$mail->body = "<h1>test 1 of phpmailer html</h1>
    <p>this is a test picture: <img src="cid:logoimg" /></p>";
$mail->altbody="this is text only alternative body.";


发送附件

 代码如下 复制代码

$mail->ishtml(false);
$mail->addattachment('www.111cn.net/invoice-user-1234.pdf', 'invoice.pdf'); // attach files/invoice-user-1234.pdf,

*/

 代码如下 复制代码

function send_msg($to,$subject,$body) {
$send_addr = 'admin@test.com';   //发送人地址
$header = "from: admin <".$send_addr."> "; //设置email头
ini_set('sendmail_from',$send_addr);
mail($to,$subject,$body,$header);
}

pop3邮箱登录

 代码如下 复制代码

function pop3_login($host,$username,$password)
{
        global $debug;
    if(empty($host)) {
        return false;
    }
    if($debug)
        echo "open hostname: ".$host.",port: ".$port." ";
    $conn = @fsockopen($host,110,$err_no,$err_str,5);
    if(!$conn) {
        return false;
    }
    $ret_info = fgets($conn,1024);
    if(substr($ret_info,0,3) == "+ok") {
                if(login($conn,$username,$password)) {
                        return true;
                }
    }
    return false;
}

smtp登录验证函数
 

 代码如下 复制代码

function smtp_login($host,$username,$password)
{
        global $debug;
    if(empty($host)) {
        return false;
    }
    if($debug)
        echo "open hostname: ".$host.",port: ".$port." ";
    $conn = @fsockopen($host,25,$err_no,$err_str,5);
    if(!$conn) {
        return false;
    }
    $ret_info = fgets($conn,1024);
    if(substr($ret_info,0,3) == "220") {
          fputs($conn,"helo localhost ");
          if(substr(fgets($conn,1024),0,3) == "250") {
                if(login($conn,$username,$password,25)) {
                        return true;
                }
          }
    }
    return false;
}

imap登录验证函数
 

 代码如下 复制代码

function imap_login($host,$username,$password)
{
        global $debug;
    if(empty($host)) {
        return false;
    }
    if($debug)
        echo "open hostname: ".$host.",port: ".$port." ";
    $conn = @fsockopen($host,143,$err_no,$err_str,5);
    if(!$conn) {
        return false;
    }
    $ret_info = fgets($conn,1024);
        if(strpos($ret_info,"ok")) {
                fputs($conn,"a001 login $username $password ");
                $ret = fgets($conn,1024);
                if(strpos($ret,"login ok")) {
                        return true;
                }
        }
        return false;
}

 

在php中发邮件会用到mail函数 ,但是大多数情情况mail函数是不可用的,我们有插件来实例了phpmailer来实现发送邮件。
 代码如下 复制代码

require("class.phpmailer.php");
$mail = new phpmailer();
$mail->charset='utf-8';
$address = $_post['address'];
$mail->issmtp();                                      // set mailer to use smtp
$mail->host = "mail.xxx.com";  // specify main and backup server
$mail->smtpauth = true;     // turn on smtp authentication
$mail->username = "phpmailer@xxx.com";  // smtp username
$mail->password = "******"; // smtp password

$mail->from = "这里应该可以填写你想要填写的邮箱";
$mail->fromname = "这里是要显示的名称";
$mail->addaddress("$address", "");
//$mail->addaddress("");                  // name is optional
//$mail->addreplyto("", "");

//$mail->wordwrap = 50;                                 // set word wrap to 50 characters
//$mail->addattachment("/var/tmp/file.tar.gz");         // add p_w_uploads
//$mail->addattachment("/tmp/image.jpg", "new.jpg");    // optional name
//$mail->ishtml(true);                                  // set email format to html

$mail->subject = "phpmailer测试邮件";
$mail->body    = "hello,这是松子的测试邮件";
$mail->altbody = "this is the body in plain text for non-html mail clients";

if(!$mail->send())
{
echo "message could not be sent. <p>";
echo "mailer error: " . $mail->errorinfo;
exit;
}

echo "message has been sent";

/*
$altbody --属性
出自:phpmailer ::$altbody
文件:class.phpmailer .php
说明:该属性的设置是在邮件正文不支持html的备用显示

addaddress --方法
出自:phpmailer ::addaddress(),文件:class.phpmailer .php
说明:增加收件人。参数1为收件人邮箱,参数2为收件人称呼。例addaddress("to@163.com","to name"),但参数2可选,addaddress(to@163.com )也是可以的。
函数原型:public function addaddress($address, $name = '') {}

addattachment --方法
出自:phpmailer ::addattachment()
文件:class.phpmailer .php。
说明:增加附件。
参数:路径,名称,编码,类型。其中,路径为必选,其他为可选
函数原型:
addattachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream'){}

addbcc --方法
出自:phpmailer ::addbcc()
文件:class.phpmailer .php
说明:增加一个密送。抄送和密送的区别请看[smtp发件中的密送和抄送的区别 ] 。
参数1为地址,参数2为名称。注意此方法只支持在win32下使用smtp,不支持mail函数
函数原型:public function addbcc($address, $name = ''){}

addcc -- 方法
出自:phpmailer ::addcc()
文件:class.phpmailer .php
说明:增加一个抄送。抄送和密送的区别请看[smtp发件中的密送和抄送的区别 ] 。
参数1为地址,参数2为名称注意此方法只支持在win32下使用smtp,不支持mail函数
函数原型:public function addcc($address, $name = '') {}

addcustomheader --方法
出自:phpmailer ::addcustomheader()
文件:class.phpmailer .php
说明:增加一个自定义的e-mail头部。
参数为头部信息
函数原型:public function addcustomheader($custom_header){}

addembeddedimage -- 方法
出自:phpmailer ::addembeddedimage()
文件:class.phpmailer .php
说明:增加一个嵌入式图片
参数:路径,返回句柄[,名称,编码,类型]
函数原型:public function addembeddedimage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {}
提示:addembeddedimage(picture_path. "index_01.jpg ", "img_01 ", "index_01.jpg ");
在html中引用<img src= "cid:img_01 ">

addreplyto --方法
出自:phpmailer :: addreplyto()
文件:class.phpmailer .php
说明:增加回复标签,如"reply-to"
参数1地址,参数2名称
函数原型:public function addreplyto($address, $name = '') {}

addstringattachment -方法
出自:phpmailer :: addstringattachment()
文件:class.phpmailer .php
说明:增加一个字符串或二进制附件(adds a string or binary attachment (non-filesystem) to the list.?)
参数:字符串,文件名[,编码,类型]
函数原型:public function addstringattachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {}

authenticate --方法
出自:smtp::authenticate()
文件:class.smtp.php
说明:开始smtp认证,必须在hello()之后调用,如果认证成功,返回true,
参数1用户名,参数2密码
函数原型:public function authenticate($username, $password) {}

b开头

$body --属性
出自:phpmailer ::$body
文件: class.phpmailer .php
说明:邮件内容,html或text格式

c开头

$charset --属性
出自:phpmailer ::$charset
文件:class.phpmailer .php
说明:邮件编码,默认为iso-8859-1

$confirmreadingto --属性
出自:phpmailer ::$confirmreadingto 文件class.phpmailer .php
说明:回执?

$contenttype --属性
出自:phpmailer ::$contenttype
文件: class.phpmailer .php
说明:文档的类型,默认为"text/plain"

$crlf --属性
出自:phpmailer ::$contenttype
文件:class.phpmailer .php
说明:smtp回复结束的分隔符(smtp reply line ending?)

class.phpmailer .php --对象
出自:class.phpmailer .php
文件: class.phpmailer .php
说明:phpmailer 对象

class.smtp.php --对象
出自:class.smtp.php 文件: class.smtp.php
说明:smtp功能的对象

clearaddresses --方法
出自:phpmailer ::clearaddresses()
文件: class.phpmailer .php
说明:清除收件人,为下一次发件做准备。返回类型是void

clearallrecipients --方法
出自:phpmailer ::clearallrecipients()
文件: class.phpmailer .php
说明:清除所有收件人,包括cc(抄送)和bcc(密送)

clearattachments --方法
出自:phpmailer ::clearattachments()
文件: class.phpmailer .php
说明:清楚附件

clearbccs --方法
出自:phpmailer ::clearbccs() 文件 class.phpmailer .php
说明:清楚bcc (密送)

clearcustomheaders --方法
出自:phpmailer ::clearcustomheaders()
文件: class.phpmailer .php
说明:清楚自定义头部

clearreplytos --方法
出自:phpmailer ::clearreplytos()
文件: class.phpmailer .php
说明:清楚回复人

close --方法
出自:smtp::close()
文件: class.smtp.php
说明:关闭一个smtp连接

connect --方法
出自:smtp::connect()
文件: class.smtp.php
说明:建立一个smtp连接mailer.html

$contenttype --属性
出自:phpmailer ::$contenttype
文件: class.phpmailer .php
说明:文档的类型,默认为"text/plain"

d开头
$do_debug --属性
出自:smtp::$do_debug
文件:class.smtp.php
说明:smtp调试输出

data -方法
出自:smtp::data()
文件:class.smtp.php
说明:向服务器发送一个数据命令和消息信息(sendsthemsg_datatotheserver)

e开头

$encoding --属性
出自:phpmailer ::$encoding
文件:class.phpmailer .php
说明:设置邮件的编码方式,可选:"8bit","7bit","binary","base64",和"quoted-printable".

$errorinfo --属性
出自:phpmailer ::$errorinfo
文件:class.phpmailer .php
说明:返回邮件smtp中的最后一个错误信息


expand --方法
出自:smtp::expand()
文件:class.smtp.php
说明:返回邮件列表中所有用户。成功则返回数组,否则返回 false(expandtakesthenameandaskstheservertolistallthepeoplewhoaremembersofthe_list_.expandwillreturnbackandarrayoftheresultorfalseifanerroroccurs.)

f开头:

$from --属性
出自:phpmailer ::$from文件class.phpmailer .php
说明:发件人e-mail地址
$fromname --属性
出自:phpmailer ::$fromname
文件:class.phpmailer .php
说明:发件人称呼

h开头:

$helo --属性
出自:phpmailer ::$helo
文件:class.phpmailer .php
说明:设置smtphelo,默认是$hostname(setsthesmtpheloofthemessage(defaultis$hostname).)

$host --属性
出自:phpmailer ::$host
文件:class.phpmailer .php
说明:设置smtp服务器,格式为:主机名[端口号],如smtp1.example.com:25和smtp2.example.com都是合法的

$hostname --属性
出自:phpmailer ::$hostname
文件:class.phpmailer .php
说明:设置在message-id和andreceivedheaders中的hostname并同时被$helo使用。如果为空,默认为server_name或'localhost.localdomain"

hello --方法
出自:smtp::hello()
文件:class.smtp.php
说明:向smtp服务器发送helo命令

help --方法
出自:smtp::help()
文件:class.smtp.php
说明:如果有关键词,得到关键词的帮助信息

i开头:

iserror --方法
出自:phpmailer ::iserror()
文件:class.phpmailer .php
说明:返回是否有错误发生

ishtml --方法
出自:phpmailer ::ishtml()
文件:class.phpmailer .php
说明:设置信件是否是html格式

ismail --方法
出自:phpmailer ::ismail()
文件:class.phpmailer .php
说明:设置是否使用php的mail函数发件

isqmail --方法
出自:phpmailer ::isqmail()
文件:class.phpmailer .php
说明:设置是否使用qmailmta来发件

issendmail-- 方法
出自:phpmailer ::issendmail()
文件:class.phpmailer .php
说明:是否使用$sendmail程序来发件

issmtp--方法
出自:phpmailer ::issmtp()
文件:class.phpmailer .php
说明:是否使用smtp来发件

m开头:

$mailer --属性
出自:phpmailer ::$mailer
文件:class.phpmailer .php
说明:发件方式,("mail","sendmail",or"smtp").中的一个

mail --方法
出自:smtp::mail()
文件:class.smtp.php
说明:从$from中一个邮件地址开始处理,返回true或false。如果是true,则开始发件

n开头:

noop-- 方法
出自:smtp::noop()
文件:class.smtp.php
说明:向smtp服务器发送一个noop命令

p开头:
$password --属性
出自:phpmailer ::$password
文件:class.phpmailer .php
说明:设置smtp的密码

$plugindir --属性
出自:phpmailer ::$plugindir
文件:class.phpmailer .php
说明:设置phpmailer 的插件目录,仅在smtpclass不在phpmailer 目录下有效

$port --属性
出自:phpmailer ::$port
文件:class.phpmailer .php
说明:设置smtp的端口号

$priority --属性
出自:phpmailer ::$priority
文件:class.phpmailer .php
说明:设置邮件投递优先等级。1=紧急,3=普通,5=不急

phpmailer --对象
出自:phpmailer
文件:class.phpmailer .php
说明:phpmailer -phpemailtransportclass

q开头

quit --方法
出自:smtp::quit()
文件:class.smtp.php
说明:向服务器发送quit命令,如果没有错误发生。那么关闭sock,不然$close_on_error为true

r开头

recipient --方法
出自:smtp::recipient()
文件:class.smtp.php
说明:使用to向smtp发送rcpt命令,参数为:$to

reset --方法
出自:smtp::reset()
文件:class.smtp.php
说明:发送rset命令从而取消处理中传输。成功则返回true,否则为false

s开头:

$sender --属性
出自:phpmailer ::$sender
文件:class.phpmailer .php
说明:setsthesenderemail(return-path)ofthemessage.ifnotempty,willbesentvia-ftosendmailoras'mailfrom'insmtpmode.

$sendmail --属性
出自:phpmailer ::$sendmail
文件:class.phpmailer .php
说明:设置发件程序的目录

$smtpauth --属性
出自:phpmailer ::$smtpauth
文件:class.phpmailer .php
说明:设置smtp是否需要认证,使用username和password变量

$smtpdebug --属性
出自:phpmailer ::$smtpdebug
文件:class.phpmailer .php
说明:设置smtp是否调试输出?

$smtpkeepalive --属性
出自:phpmailer ::$smtpkeepalive
文件:class.phpmailer .php
说明:在每次发件后不关闭连接。如果为true,则,必须使用smtpclose()来关闭连接

$smtp_port --属性
出自:smtp::$smtp_port
文件:class.smtp.php
说明:设置smtp端口

$subject --属性
出自:phpmailer ::$subject
文件:class.phpmailer .php
说明:设置信件的主题

send --方法
出自:smtp::send()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

send --方法
出自:phpmailer ::send()
文件:class.phpmailer .php
说明:创建邮件并制定发件程序。如果发件不成功,则返回false,请使用errorinfo来查看错误信息

sendandmail --方法
出自:smtp::sendandmail()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

sendormail --方法
出自:smtp::sendormail()
文件:class.smtp.php
说明:从指定的邮件地址开始一个邮件传输

setlanguage --方法
出自:phpmailer ::setlanguage()
文件:class.phpmailer .php
说明:设置phpmailer 错误信息的语言类型,如果无法加载语言文件,则返回false,默认为english

smtp --方法
出自:smtp::smtp()
文件:class.smtp.php
说明:初始化一个对象以便数据处于一个已知的状态

smtp --对象
出自:smtp
文件:class.smtp.php
说明:smtp对象

smtpclose --方法
出自:phpmailer ::smtpclose()
文件:class.phpmailer .php
说明:如果有活动的smtp则关闭它。

t开头

$timeout --属性
出自:phpmailer ::$timeout
文件:class.phpmailer .php
说明:设置smtp服务器的超时(单位:秒)。注意:在win32下,该属性无效

turn --方法
出自:smtp::turn()
文件:class.smtp.php
说明:这是一个可选的smtp参数,目前phpmailer 并不支持他,可能未来支持

u开头

$username --属性
出自:phpmailer ::$username
文件:class.phpmailer .php
说明:设置smtp用户名

v开头

$version --属性
出自:phpmailer ::$version
文件:class.phpmailer .php
说明:返回phpmailer 的版本

verify --方法
出自:smtp::verify()
文件:class.smtp.php
说明:通过服务器检查用户名是否经过验证

w开头:

$wordwrap --属性
出自:phpmailer ::$wordwrap
文件:class.phpmailer .php
说明:设置每行最大字符数,超过改数后自动换行

*/
?>

[!--infotagslink--]

相关文章

  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
  • NodeJS实现阿里大鱼短信通知发送

    本文给大家介绍的是nodejs实现使用阿里大鱼短信API发送消息的方法和代码,有需要的小伙伴可以参考下。...2016-01-20
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • 几种延迟加载JS代码的方法加快网页的访问速度

    本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
  • PHP测试成功的邮件发送案例

    mail()函数的作用:连接到邮件服务器,利用smtp协议,与该服务器交互并投邮件。注意:1、mail函数不支持esmtp协议,---即,只能直投,不能登陆2、由上条,我们只能直投至最终的收件服务器地址.而该地址,又是在PHP.ini中指定的,所...2015-10-30
  • php导出csv格式数据并将数字转换成文本的思路以及代码分享

    php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07
  • ecshop商品无限级分类代码

    ecshop商品无限级分类代码 function cat_options($spec_cat_id, $arr) { static $cat_options = array(); if (isset($cat_options[$spec_cat_id]))...2016-11-25
  • php邮件发送的两种方式

    这篇文章研究的主要内容就是使用PHP来发送电子邮件,总结为以下两种方法:一、使用PHP内置的mail()函数<&#63;php $to = "test@163.com"; //收件人 $subject = "Test"; //主题 $message = "This is a test mail!"; //正文...2015-10-30