盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

PHP一个发送邮件的类

时间:2024/12/12作者:未知来源:盾怪网教程人气:

[摘要]!(fp = @fopen(this->log_file, "a"))) this->smtp_debug("Warning: Ca...
!($fp = @fopen($this->log_file, "a"))) {


            $this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n");


            return FALSE;;


        }


        flock($fp, LOCK_EX);


        fputs($fp, $message);


        fclose($fp);



        return TRUE;


    }



    function strip_comment($address)


    {


        $comment = "\([^()]*\)";


        while (ereg($comment, $address)) {


            $address = ereg_replace($comment, "", $address);


        }



        return $address;


    }



    function get_address($address)


    {


        $address = ereg_replace("([ \t\r\n])+", "", $address);


        $address = ereg_replace("^.*<(.+)>.*$", "\1", $address);


        return $address;


    }


    function smtp_debug($message)


    {


        if ($this->debug) {


        echo $message;


        }


    }


}


?>


//*****************************************************************
// *.php 使用文件,看清楚了,怎么使用在这里
//
//*****************************************************************

<?

require (FILE_DIR."smtp.php");

$smtpserver = "smtp.xxx.com";//SMTP服务器


$smtpserverport =25;//SMTP服务器端口


$smtpusermail = "xxxxx@xxx.com";//SMTP服务器的用户邮箱


$smtpemailto = "aaaaa@xxx.com";//发送给谁


$smtpuser = "xxxxx";//SMTP服务器的用户帐号


$smtppass = "xxxxx";//SMTP服务器的用户密码


$mailsubject = "Test Subject";//邮件主题


$mailbody = "<h1>This is a test mail</h1>";//邮件内容


$mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件


$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.


$smtp->debug = TRUE;//是否显示发送的调试信息


$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);


?>

关键词:PHP一个发送邮件的类




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版