static function SmtpMail($from, $to, $subject, $message, $options = null, $bcc = array()) { /* settings */ if (!isset($options['subjectenc'])) { $options['subjectenc'] = 'UTF-8'; } if (!isset($options['encoding'])) { $options['encoding'] = 'UTF-8'; } if (!isset($options['contentType'])) { $options['contentType'] = 'text/plain'; } if ('UTF-8' != $options['encoding']) { $message = mb_convert_encoding($message, $options['encoding'], 'UTF-8'); } global $INI; /* get from ini */ $host = $INI['mail']['host']; $port = $INI['mail']['port']; $ssl = $INI['mail']['ssl']; $user = $INI['mail']['user']; $pass = $INI['mail']['pass']; $from = $INI['mail']['from']; $reply = $INI['mail']['reply']; $site = $INI['system']['sitename']; //SAE 邮件发送 $ishtml = $options['contentType'] == 'text/html'; if ($ishtml) { $ContentType = 'HTML'; } else { $ContentType = 'TEXT'; } $options = array('to' => $to, 'subject' => $subject, 'content' => $message, 'content_type' => $ContentType, 'smtp_username' => $user, 'smtp_password' => $pass, 'from' => $from); $mail = new SaeMail($options); $ret = $mail->Send(); //发送失败时输出错误码和错误信息 if ($ret === false) { sae_debug($mail->errmsg()); } $mail->clean(); return $ret; /* $subject = self::EscapeHead($subject, $options['subjectenc']); $site = self::EscapeHead($site, $options['subjectenc']); $body = $message; $ishtml = ($options['contentType']=='text/html'); //begin $mail = new PHPMailer(); $mail->IsSMTP(); $mail->CharSet = $options['encoding']; $mail->SMTPAuth = true; $mail->Host = $host; $mail->Port = $port; if ( $ssl=='ssl' ) { $mail->SMTPSecure = "ssl"; } else if ( $ssl == 'tls' ) { $mail->SMTPSecure = "tls"; } $mail->Username = $user; $mail->Password = $pass; $mail->SetFrom($from, $site); $mail->AddReplyTo($reply, $site); foreach($bcc AS $bo) { $mail->AddBCC($bo); } $mail->Subject = $subject; if ( $ishtml ) { $mail->MsgHTML($body); } else { $mail->Body = $body; } $mail->AddAddress($to); return $mail->Send(); */ }