工作中~
分类:
2008-08-27 14:33:29
SHELL="/bin/sh"
logfile "/var/log/maildrop.log"
if (/^From:.*/)
{
SENDERMAILADD=getaddr($MATCH)
}
if (/^Subject:.*/)
{
SUBJECT=$MATCH
}
if ($SUBJECT ne "")
{
NSUB=`/usr/bin/maildecode $SUBJECT `
}
xfilter '/usr/local/bin/php -q /var/www/oa/webroot/SMS/mail_sms.php "$SENDERMAILADD" "$LOGNAME" "$NSUB" "$SIZE"'(不知道为啥,加上以后能得到消息提醒,但到收件箱却收不到邮件了。)
############ Spam Filtering ###############
CUSTOM_FILTER="$HOME/.mailfilter"
#`$TEST $CUSTOM_FILTER && exit 1 || exit 0`
if ( $RETURNCODE == 0 )
{
to "$HOME/Maildir"
}
#!/usr/bin/php
include_once("/var/www/oa/webroot/inc/conn.php");//基于通达OA做的集成
$FromName = str_replace("\r","",str_replace("\n","",trim($argv[1])));
$To = trim($argv[2]);
$Subject = trim($argv[3]);
$Size = $argv[4];
if ($Size < 1048576 && $Size >= 1024 ){
$SizeB = ceil("$Size/1024")."K";
}elseif ($Size>=1048576 && $Size<1073741824){
$SizeB = ceil("$Size/(1024*1024)")."M";
}elseif ($Size>=1073741824){
$SizeB = ceil("$Size/(1024*1024*1024)")."G";
}else {
$SizeB = $Size."B";
}
$CONTENT = "收到".$FromName."新邮件:".$Subject;
$LenStr = 70-6-strlen($SizeB)-5;//70个字-[公司名称](6个字位),由于短信网关只支持70个字位
$CONTENT = Substring($CONTENT,$LenStr)."...共计".$SizeB."";
//echo($CONTENT);
//以下为搜索用户对应手机号
$query = "select `MOBIL_NO`,`USER_ID` from `USER` where `username`='$To'";
$cursor = exequery($connection, $query);
while($ROW = mysql_fetch_array($cursor)){
$PHONE = $ROW['MOBIL_NO'];
$USER_ID = $ROW['USER_ID'];
}
//添加到短信发送表
//echo("\r".$PHONE."|".$USER_ID);
if(strrpos("2312?",$Subject) <1 && strlen($PHONE) == 11){
$query = "insert into `SMS2` (`FROM_ID`,`PHONE`,`CONTENT`,`SEND_FLAG`,`REGO`) values ('admin','$PHONE','$CONTENT','0',0)";
$cursor = exequery($connection, $query);
}
if ($SYS_RTX_SER==1){//与RTX集成,由于OA放在FreeBSD上,基于Nusoap做的Webservice
require_once("/var/www/oa/webroot/inc/nusoap.php");//webservice地址
$client = new soapclient($SYS_WEBSERVICE,true);
$title = "收到来自于".$FromName."的新邮件";
$parameters=array($USER_ID,$CONTENT,$title,0,1,0);
$str=$client->call('RTXMess',$parameters);//发送消息给RTX,通知用户
}
function Substring($str,$max){//截取字串
//$str字符串
//$max 最大字符数
$cnt=0; //实际计数
$index=0; //当前索引
$output=''; //输出
//
while($cnt<$max && $index$output.=$str[$index];
//big5
if(ord($str[$index])>=0x81 && ord($str[$index])<=0xfe){
if($index+1if( (ord($str[$index+1])>=0x40 && ord($str[$index+1])<0x7e)
|| (ord($str[$index+1])>=0xa1 && ord($str[$index+1])<=0xfe) ){
$index++;
$output.=$str[$index];
}
}
}
//gb2312
else if(ord($str[$index])>=0xa1 && ord($str[$index])<=0xf7){
$output.=$str[$index];
if($index+1if(ord($str[$index+1])>=0xa1 && ord($str[$index+1])<0xfe){
$index++;
$output.=$str[$index];
}
}
}
else{
}
$cnt++;
$index++;
}
return $output;
}
?>
chinaunix网友2008-09-09 08:58:06
针对这个功能,还善未去实现,如果有什么问题的话,大家可以去 http://www.extmail.org/forum/viewthread.php?tid=8528&highlight=%2Bcnjustice 看看,这个帖子的楼主,实现过这个功能