歡迎您光臨本站 註冊首頁

perl監控XP-PRO系統Exchange郵件容量

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

perl監控XP-PRO系統Exchange郵件容量

#該程序實驗目的:
#當用戶個人文件夾的郵件達到3G的時候,系統自動回復一封警告郵件(提醒用戶更改郵件送達位置,即新建個人文件夾)。
#藉此,引伸:通過特定埠訪問區域網所有PC(client),進行監控併發出警告郵件(這個目前我不會,請教)
程序:

opendir(DIRMAIL, "D:/Mail") or die "$!";
my @allfiles = grep { not /^\.{1,2}\z/ } readdir DIRMAIL;
closedir DIRMAIL;
die "No file names supplied!\n" unless @allfiles;

my $youngest_name = shift @allfiles;
my $youngest_age = -M $youngest_name;
   foreach (@allfiles) {
      my $age = -M;
      ($youngest_name, $youngest_age) = ($_, $age)
         if $age < $youngest_age;
   }
printf "The youngest file was %s, and it was %.1f days old.\n",
      $youngest_name, $youngest_age;
   if (-s 'd:/Mail/'.$youngest_name >3000000000){# "-s":byte

       use Net::SMTP; #use model:Net::SMTP

       my $mailhost = "##########"; # the smtp host
       my $mailfrom = '######'; # your email address
       my @mailto = ('######'); # the recipient list
       my $subject = "個人文件夾的郵件超出3G限制";
       my $text = "溫馨提示:\n您的個人文件夾郵件超過3G限制,請您新建一個新的個人文件夾以防止無法接收郵件\n詳細設置方法為......";

       $smtp = Net::SMTP->new($mailhost, Hello => 'localhost', Timeout => 120, Debug => 1);

       # anth login, type your user name and password here
       #$smtp->auth('user','pass');

          foreach my $mailto (@mailto) {
             # Send the From and Recipient for the mail servers that require it
             $smtp->mail($mailfrom);
             $smtp->to($mailto);

             # Start the mail
             $smtp->data();

             # Send the header
             $smtp->datasend("To: $mailto\n");
             $smtp->datasend("From: $mailfrom\n");
             $smtp->datasend("Subject: $subject\n");
             $smtp->datasend("\n");

             # Send the message
             $smtp->datasend("$text\n\n");

             # Send the termination string
             $smtp->dataend();
          }
       $smtp->quit;
   }
這裡,什麼方法可以實現用程序監控整個區域網Client端PC(XP-PRO系統)?
要學以致用,呵呵,請老大們指教啊!先謝謝了!
注:將perl版發的帖子發這裡來了,希望得到大家的幫助!

[ 本帖最後由 windows.li 於 2007-9-19 14:31 編輯 ]
《解決方案》

換個版塊發這帖子,也是沒有人響應啊!
有誰會的,請指教啊,感激不盡!
《解決方案》

###

[ 本帖最後由 mouse.rice 於 2008-2-20 16:45 編輯 ]

[火星人 ] perl監控XP-PRO系統Exchange郵件容量已經有334次圍觀

http://coctec.com/docs/service/show-post-32362.html