日期:2014-05-17 浏览次数:20722 次
第一步:php连接数据库:dbconnection.php
<?php
$server = "(local)";
$_uid = "adweb";
$_pwd = "loveyou";
$_database = "addev";
function sqlsrv_num_rows($n) {
}
function sqlsrv_fetch_array($n) {
}
//调用函数,连接数据库
$conn = sqlsrv_connect( $server , $_uid ,$_pwd,$_database
?>
第二步:邮箱类email.class.php
<?
class smtp
{
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;
var $sock;
function smtp($relay_host = "", $smtp_port = 25,$auth =false,$user,$pass)
{
$this->debug = FALSE;
$this->smtp_port = $smtp_port;
$this->relay_host = $relay_host;
$this->time_out = 30; //is used in fsockopen()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; //is used in HELOcommand
$this->log_file ="";
$this->sock = FALSE;
}
function sendmail($to, $from, $subject = "", $body = "", $mailtype,$cc = "", $bcc = "", $additional_headers = "")
{
$mail_from =$this->get_address($this->strip_comment($from));
$body = ereg_replace("(^|(\r\n))(\\.)", "\\1.\\3", $body);
$header .= "MIME-Version:1.0\r\n";
if($mailtype=="HTML"){
$header .= "Content-Type:text/html\r\n";
}
$header .= "To: ".$to."\r\n";
if ($cc != "") {
$header .= "Cc: ".$cc."\r\n";
}
$header .= "From:$from<".$from.">\r\n";
$header .= "Subject: ".$subject."\r\n";
$header .= $additional_headers;
$header .= "Date: ".date("r")."\r\n";
$header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
list($msec, $sec) = explode(" ", microtime());
$header .=