<?php
  require("smtp.php"); 

  function SendMail($to,$subject,$mailcontent,$from)
  {
    $array = split("@",$from,2);
    $SERVER_NAME = $array[1];
    $username =$array[0];
    $fromnew = "From: $username@$SERVER_NAME\nReply-To:$username@$SERVER_NAME\nX-Mailer: PHP";
     mail($to,$subject,$mailcontent,$fromnew);
  }
  function SendHTMLMail_old($to,$subject,$mailcontent,$from)
  {
    $array = split("@",$from,2);
    $SERVER_NAME = $array[1];
    $username =$array[0];
    $headers = "From: $username@$SERVER_NAME\nReply-To:$username@$SERVER_NAME\nX-Mailer: PHP\n";

    $limite = "_parties_".md5 (uniqid (rand()));

    $headers .= "Date: ".date("l j F Y, G:i")."\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/html;\n";
    $headers .= " boundary=\"----=$limite\"\n\n";

    mail($to,$subject,$mailcontent,$headers);
  }
  
  function SendHTMLMail($to,$subject,$mailcontent,$from)
  {		
		$smtpemailto = $to;//发送给谁
/*
		$smtpserver = "smtp.139.com";//SMTP服务器
		$smtpserverport =25;//SMTP服务器端口
		$smtpusermail = "fdx899@139.com";//SMTP服务器的用户邮箱
		$smtpuser = "fdx899@139.com";//SMTP服务器的用户帐号
		$smtppass = "173173";//SMTP服务器的用户密码
*/		
    
		$qrysel = "select * from general_setting where id='1'";
		$ressel = mysql_query($qrysel);
		$row = mysql_fetch_object($ressel);
		
		$smtpserver = $row->smtpserver;//SMTP服务器
		$smtpserverport =$row->smtpserverport;//SMTP服务器端口
		$smtpusermail = $row->smtpusermail;//SMTP服务器的用户邮箱
		$smtpuser = $row->smtpuser;//SMTP服务器的用户帐号
		$smtppass = $row->smtppass;//SMTP服务器的用户密码
		//echo $smtpserver." ".$smtpserverport." ".$smtpusermail." ".$smtpuser." ".$smtppass;
		
		$mailsubject = $subject;//邮件主题
		$mailbody = $mailcontent;//邮件内容
		$mailtype = "HTML";//邮件格式（HTML/TXT）,TXT为文本邮件
		$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
		$smtp->debug = FALSE;//是否显示发送的调试信息
		$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);
	}
  
?>