【php开源代码栏目提醒】:网学会员为广大网友收集整理了,XPertMailer.php,希望对大家有所帮助!
<?php
/***************************************************************************************
* XPertMailer Version 1.4.5 Stable - 5/16/2006 3:21 PM *
* *
* This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/) *
* *
* XPertMailer is free software; you can redistribute it and/or modify it under the *
* terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later version. *
* *
* XPertMailer is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* XPertMailer; if not, write to the Free Software Foundation, Inc., 51 Franklin St, *
* Fifth Floor, Boston, MA 02110-1301 USA *
* *
* XPertMailer php functions class. Sends e-mail message in MIME type format. *
* Copyright (C) 2006 Tanase Laurentiu Iulian *
* *
***************************************************************************************/
if(!defined('PRINT_ERROR')) define('PRINT_ERROR', true);
if(isset($_CONSTS_NAME) && PRINT_ERROR) trigger_error("Variable '\$_CONSTS_NAME' it is already defined", 256);
if(isset($_NAME_CONSTS) && PRINT_ERROR) trigger_error("Variable '\$_NAME_CONSTS' it is already defined", 256);
if(isset($_VALUE_CONST) && PRINT_ERROR) trigger_error("Variable '\$_VALUE_CONST' it is already defined", 256);
$_CONSTS_NAME = array(
'SMTP_LOCAL' => 1,
'SMTP_CLIENT' => 2,
'SMTP_LOCAL_CLIENT' => 3,
'SMTP_CLIENT_LOCAL' => 4,
'SMTP_RELAY' => 5,
'SMTP_RELAY_CLIENT' => 6,
'SMTP_CLIENT_RELAY' => 7,
'AUTH_DETECT' => 1,
'AUTH_LOGIN' => 2,
'AUTH_PLAIN' => 3,
'MX_FALSE' => false,
'MX_TRUE' => true,
'ATTACH_HTML_IMG' => 1,
'ATTACH_FILE' => 2,
'CLEAR_
HTML_IMG' => 1,
'CLEAR_FILE' => 2,
'CLEAR_ALL' => 3,
'P_LOW' => 1,
'P_NORMAL' => 2,
'P_HIGH' => 3,
'SSL_FALSE' => false,
'SSL_TRUE' => true,
'CRLF' => "\r\n",
'IS_WIN' => (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
);
foreach($_CONSTS_NAME as $_NAME_CONSTS => $_VALUE_CONST){
if(defined($_NAME_CONSTS)){
if(PRINT_ERROR) trigger_error("The constant '".$_NAME_CONSTS."' it is already defined", 256);
}else define($_NAME_CONSTS, $_VALUE_CONST);
}
class XPertMailer
{
var $_setsmtp = 3;
var $_pnumber = 25;
var $_porelay = 25;
var $_timeout = 30;
var $_setarrh;
var $_attc1st;
var $_attc2nd;
var $_subject;
var $_fromadr;
var $_sslconn = false;
var $_fromail = false;
var $_fromnam = false;
var $_partmix;
var $_part1st;
var $_part2nd;
var $_wheaders;
var $_wmessage;
var $_wattachs;
var $_msgsplit;
var $_authuser;
var $_authpass;
var $_relayset;
var $_authsets = false;
var $_priority = false;
var $_charset = "gb2312";
var $response = "unknow";
function XPertMailer($smtp = 3, $relay = false){
if(is_int($smtp) && $smtp >= 1 && $smtp <= 7){
if($smtp >= 5){
if(!$relay){
if(PRINT_ERROR) trigger_error("The relay host name or ip address is not set on class XPertMailer->constructor", 512);
}else{
if(is_string($relay) && trim($relay) != ""){
$this->_setsmtp = $smtp;
$this->_relayset = $relay;
}elseif(PRINT_ERROR) trigger_error("Invalid relay host name or ip address on class XPertMailer->constructor", 512);
}
}else $this->_setsmtp = $smtp;
}elseif(PRINT_ERROR) trigger_error("Invalid SMTP connection preference value on class XPertMailer->constructor", 512);
$this->_setarrh = $this->_attc1st = $this->_attc2nd = $this->_msgsplit = array();
}
function timeout($tmout){
if(is_int($tmout)) $this->_timeout = $tmout;
elseif(PRINT_ERROR) trigger_error("Invalid parameter type on class XPertMailer->timeout()", 512);
}
function auth($user, $pass, $type = 1, $vssl = false, $prelay = 25){
if(is_string($user) && is_string($pass) && !empty($user) && !empty($pass)){
$this->_authuser = $user;
$this->_authpass = $pass;
if(is_int($type) && ($type == 1 || $type == 2 || $type == 3)) $this->_authsets = $type;
else{
$this->_authsets = 1;
if(PRINT_ERROR) trigger_error("Invalid 3'rd auth parameter type on class XPertMailer->auth()", 512);
}
if(is_bool($vssl)){
if($vssl){
if(extension_loaded('openssl')){
$this->_sslconn = true;
if(is_i