gdufo

 

通达OA 增加外发邮件功能

  在utility_all.php的690行增加
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);
     }
   }
}

posted on 2013-03-06 10:53 gdufo 阅读(1433) 评论(0)  编辑  收藏 所属分类: OA(Moss+Infopath)

导航

统计

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

Hibernate

友情链接

搜索

最新评论

阅读排行榜

评论排行榜