function send_webmail_ext($USER_STR, $CC_STR,$SUBJECT,$CONTENT)
{
global $connection,$LOGIN_USER_ID,$LOGIN_USER_NAME,$RUN_ID;
$query = "SELECT * from WEBMAIL where USER_ID='admin'";
$cursor= exequery($connection,$query);
if($ROW=mysql_fetch_array($cursor))
{
$EMAIL=$ROW["EMAIL"];
$SMTP_SERVER=$ROW["SMTP_SERVER"];
$LOGIN_TYPE=$ROW["LOGIN_TYPE"];
$SMTP_PASS=$ROW["SMTP_PASS"];
$SMTP_PORT=$ROW["SMTP_PORT"];
$SMTP_SSL=$ROW["SMTP_SSL"]=="1" ? "ssl":"";
$EMAIL_PASS=$ROW["EMAIL_PASS"];
$EMAIL_PASS=decrypt_str($EMAIL_PASS,"webmail");
if($LOGIN_TYPE=="1")
$SMTP_USER = substr($EMAIL,0,strpos($EMAIL,"@")); // SMTP username
else
$SMTP_USER =$EMAIL;
if($SMTP_PASS=="yes")
$SMTP_PASS = $EMAIL_PASS; // SMTP password
else
$SMTP_PASS = "";
$USER_ARRAY=explode(",",$USER_STR);
//接收人
$query = "select USER_ID,EMAIL from USER WHERE find_in_set(USER_ID,'$USER_STR')";
echo $query;
$cursor = exequery($connection,$query);
while($ROW=mysql_fetch_array($cursor))
{
$USER_ID=$ROW["USER_ID"];
/*if($USER_ID==$LOGIN_USER_ID)
continue;*/
$TO_EMAIL=$ROW["EMAIL"];
/*if($TO_EMAIL=="")
{
$query1 = "select EMAIL from WEBMAIL WHERE USER_ID='$USER_ID' limit 1";
$cursor1 = exequery($connection,$query1);
if($ROW1=mysql_fetch_array($cursor))
$TO_EMAIL=$ROW["EMAIL"];
}
if($TO_EMAIL != "") */
$TO_WEBMAIL.=$TO_EMAIL.",";
}
//抄送
$query = "select USER_ID,EMAIL from USER WHERE (EMAIL IS NOT NULL AND EMAIL<>'') AND find_in_set(USER_ID,'$CC_STR')";
$cursor = exequery($connection,$query);
while($ROW=mysql_fetch_array($cursor))
{
$USER_ID=$ROW["USER_ID"];
/*if($USER_ID==$LOGIN_USER_ID)//本人
continue;*/
$CC_EMAIL=$ROW["EMAIL"];
/*if($TO_EMAIL=="")
{
$query1 = "select EMAIL from WEBMAIL WHERE USER_ID='$USER_ID' limit 1";
$cursor1 = exequery($connection,$query1);
if($ROW1=mysql_fetch_array($cursor))
$TO_EMAIL=$ROW["EMAIL"];
}*/
$CC_WEBMAIL.=$CC_EMAIL.",";
}
$result=send_mail($EMAIL,$TO_WEBMAIL,$SUBJECT,$CONTENT,$SMTP_SERVER,$SMTP_USER,$SMTP_PASS,true,$LOGIN_USER_NAME,'',$CC_WEBMAIL,'','',true,$SMTP_PORT,$SMTP_SSL);
if($result===true)
{
Message("提示","外部邮件发送成功");
}
else
{
Message("外部邮件发送失败",$result);
}
}
}