function sendmail($to, $from, $subject, $content, $T = 0) { global $webdb; //$name, $email, $subject, $content, $type=0 $type = 1; //$name=array("{$webdb[webname]}会员"); $email = array($to); $_CFG['smtp_host'] = $this->host; $_CFG['smtp_port'] = $this->port; $_CFG['smtp_user'] = $this->user; $_CFG['smtp_pass'] = $this->pass; $_CFG['name'] = $webdb[webname]; $_CFG['smtp_mail'] = $from; if (WEB_LANG == 'big5') { require_once ROOT_PATH . "inc/class.chinese.php"; $cnvert = new Chinese("BIG5", "GB2312", $subject, ROOT_PATH . "./inc/gbkcode/"); $subject = $cnvert->ConvertIT(); $cnvert = new Chinese("BIG5", "GB2312", $content, ROOT_PATH . "./inc/gbkcode/"); $content = $cnvert->ConvertIT(); //$cnvert = new Chinese("BIG5","GB2312",$name,ROOT_PATH."./inc/gbkcode/"); //$name = $cnvert->ConvertIT(); $cnvert = new Chinese("BIG5", "GB2312", $_CFG['name'], ROOT_PATH . "./inc/gbkcode/"); $_CFG['name'] = $cnvert->ConvertIT(); } elseif (WEB_LANG == 'utf-8') { require_once ROOT_PATH . "inc/class.chinese.php"; $cnvert = new Chinese("UTF8", "GB2312", $subject, ROOT_PATH . "./inc/gbkcode/"); $subject = $cnvert->ConvertIT(); $cnvert = new Chinese("UTF8", "GB2312", $content, ROOT_PATH . "./inc/gbkcode/"); $content = $cnvert->ConvertIT(); //$cnvert = new Chinese("UTF8","GB2312",$name,ROOT_PATH."./inc/gbkcode/"); //$name = $cnvert->ConvertIT(); $cnvert = new Chinese("UTF8", "GB2312", $_CFG['name'], ROOT_PATH . "./inc/gbkcode/"); $_CFG['name'] = $cnvert->ConvertIT(); } //$name = "=?UTF-8?B?".base64_encode($name)."==?="; $subject = "=?gbk?B?" . base64_encode($subject) . "==?="; $content = base64_encode($content); $headers[] = "To:=?gbk?B?" . base64_encode($name[0]) . "?= <{$email['0']}>"; $headers[] = "From:=?gbk?B?" . base64_encode($_CFG[name]) . "?= <{$_CFG['smtp_mail']}>"; $headers[] = "MIME-Version: "; $headers[] = "X-Mailer: "; //$headers[] = "From:=?UTF-8?B?".base64_encode($_CFG['shop_name'])."==?=<$_CFG[smtp_mail]>"; $headers[] = "Subject:{$subject}"; $headers[] = $type == 0 ? "Content-Type: text/plain; charset=gbk; format=flowed" : "Content-Type: text/html; charset=gbk; format=flowed"; $headers[] = "Content-Transfer-Encoding: base64"; $headers[] = "Content-Disposition: inline"; // SMTP 服务器信息 $params['host'] = $_CFG['smtp_host']; $params['port'] = $_CFG['smtp_port']; $params['user'] = $_CFG['smtp_user']; $params['pass'] = $_CFG['smtp_pass']; if (empty($params['host']) || empty($params['port'])) { // 如果没有设置主机和端口直接返回 false return false; } else { // 发送邮件 $send_params['recipients'] = $email; $send_params['headers'] = $headers; $send_params['from'] = $_CFG['smtp_mail']; $send_params['body'] = $content; /* echo "<pre>"; print_r($params); print_r($send_params); echo "</pre>"; exit; */ $smtp = new qb_smtp($params); if ($smtp->connect() and $smtp->send($send_params)) { return TRUE; } else { return FALSE; } // end if } }
function sendmail($to, $from, $subject, $content, $T = 0) { global $webdb; //$name, $email, $subject, $content, $type=0 $type = 1; $name = array("{$webdb[webname]}会员"); $email = array($to); $_CFG['smtp_host'] = $this->host; $_CFG['smtp_port'] = $this->port; $_CFG['smtp_user'] = $this->user; $_CFG['smtp_pass'] = $this->pass; $_CFG['name'] = $webdb[webname]; $_CFG['smtp_mail'] = $from; //$name = "=?UTF-8?B?".base64_encode($name)."==?="; $subject = "=?gbk?B?" . base64_encode($subject) . "==?="; $content = base64_encode($content); $headers[] = "To:=?gbk?B?" . base64_encode($name[0]) . "?= <{$email['0']}>"; $headers[] = "From:=?gbk?B?" . base64_encode($_CFG[name]) . "?= <{$_CFG['smtp_mail']}>"; $headers[] = "MIME-Version: Blueidea v1.0"; $headers[] = "X-Mailer: 9gongyu Mailer v1.0"; //$headers[] = "From:=?UTF-8?B?".base64_encode($_CFG['shop_name'])."==?=<$_CFG[smtp_mail]>"; $headers[] = "Subject:{$subject}"; $headers[] = $type == 0 ? "Content-Type: text/plain; charset=gbk; format=flowed" : "Content-Type: text/html; charset=gbk; format=flowed"; $headers[] = "Content-Transfer-Encoding: base64"; $headers[] = "Content-Disposition: inline"; // SMTP 服务器信息 $params['host'] = $_CFG['smtp_host']; $params['port'] = $_CFG['smtp_port']; $params['user'] = $_CFG['smtp_user']; $params['pass'] = $_CFG['smtp_pass']; if (empty($params['host']) || empty($params['port'])) { // 如果没有设置主机和端口直接返回 false return false; } else { // 发送邮件 $send_params['recipients'] = $email; $send_params['headers'] = $headers; $send_params['from'] = $_CFG['smtp_mail']; $send_params['body'] = $content; /* echo "<pre>"; print_r($params); print_r($send_params); echo "</pre>"; exit; */ $smtp = new qb_smtp($params); if ($smtp->connect() and $smtp->send($send_params)) { return TRUE; } else { return FALSE; } // end if } }