<?php
/*邮件发送*/
class Mail {
	public $mail;
	public $config;
	public function __construct(){
		$this->config = $GLOBALS['config'];
		$this->mail = new Easy_Mail();
	}
	public function sendMail($to , $subject, $mailbody){
		$array['server'] = $this->config['smtp'];
		$array['port'] = $this->config['port'];
		$array['user'] = $this->config['smtpuser'];
		$array['pass'] = $this->config['smtpass'];
		$array['from'] = $this->config['sitemail'];
		$this->mail->server[] = $array;
		if (is_array($to)){
			$this->mail->to =  $to;
		}else{
			$this->mail->to =  explode(',', $to);
		}
		$this->mail->subject = $subject;
		if (!$mailbody){
			exit('邮件内容必须填写');
		}
		$mailbody = str_replace('[sitename]', $this->config['sitename'], $mailbody );
		$mailbody = str_replace('[domain]', $this->config['domain'], $mailbody );
		$mailbody = str_replace('[qq]', $this->config['qq'], $mailbody );
		$mailbody = str_replace('[sitemail]', $this->config['sitemail'], $mailbody );
		$mailbody = str_replace('[phone]', $this->config['phone'], $mailbody );
		$this->mail->htmlbody = $mailbody;
		if($this->mail->sendmail()===true){
			return true;
		}else{
			$this->ErrorInfo = $this->mail->ErrorInfo;
			return false;
		}
	}
}
?>