mail.php

来自「a short sketch about linux syntex lines.」· PHP 代码 · 共 40 行

PHP
40
字号
<?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;
		}
	}
}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?