public static function config($config = array()) { if (!is_array($config)) { return false; } self::$config = $config; self::$mail = System::load_sys_class("phpmailer"); self::$mail->IsSMTP(); // 启用SMTP self::$mail->Host = $config['stmp_host']; //SMTP服务器 self::$mail->SMTPAuth = true; //开启SMTP认证 self::$mail->Username = $config['user']; // SMTP用户名 self::$mail->Password = $config['pass']; // SMTP密码 self::$mail->From = $config['from']; //发件人地址 self::$mail->FromName = $config['fromName']; //发件人 self::$mail->AddReplyTo($config['from'], $config['fromName']); //回复地址 self::$mail->WordWrap = 50; //设置每行字符长度 }
/** * 发送电子邮件 * @email 也可以是一个二维数组,包含邮件和用户名信息 **/ function _sendemail($email, $username = null, $title = '', $content = '', $yes = '', $no = '') { System::load_sys_class("email", 'sys', "no"); $config = System::load_sys_config('email'); if (!$username) { $username = ""; } if (!$yes) { $yes = "发送成功,如果没有收到,请到垃圾箱查看,\n请把" . $config['fromName'] . "设置为信任,方便以后接收邮件"; } if (!$no) { $no = "发送失败,请重新点击发送"; } if (!_checkemail($email)) { return false; } email::config($config); if (is_array($email)) { email::adduser($email); } else { email::adduser($email, $username); } $if = email::send($title, $content); if ($if) { return $yes; } else { return $no; } }