php實現(xiàn)統(tǒng)計郵件大小的方法
統(tǒng)計用戶收件箱所占空間有多少,先計算每封郵件的大?。?biāo)題+內(nèi)容+附近),后總和;
1、計算附近大?。?BR>2、計算標(biāo)題和內(nèi)容大小
3、總和求出單封郵件大小
案例:
<?php
$attach_size= 0;
if($attachmentid){ //獲取附近的大小
$attach_data= attachdata($attachmentid);
if($attach_data){
foreach($attach_dataas$value) {
$attach_size+= $value['filesize'];
}
}
}
//獲取標(biāo)題和郵件內(nèi)容的大小
$email_content_size= 0;
$_filename= "attachment/emailsizecalculate.tmp";
$_file= fopen($_filename, "wb");
fwrite($_file, $subject.$content);
fclose($_file);
if($_temp= filesize($_filename)){
$email_content_size= $_temp;
}
$del_ret= @unlink($_filename);
$sum_size= $attach_size*1024 + $email_content_size; //郵件總大小
?>
相關(guān)文章
php基于mcrypt_encrypt和mcrypt_decrypt實現(xiàn)字符串加密解密的方法
這篇文章主要介紹了php基于mcrypt_encrypt和mcrypt_decrypt實現(xiàn)字符串加密解密的方法,結(jié)合實例形式分析了mcrypt_encrypt和mcrypt_decrypt函數(shù)進(jìn)行加密、解密的相關(guān)使用技巧,需要的朋友可以參考下2016-07-07探討PHP函數(shù)ip2long轉(zhuǎn)換IP時數(shù)值太大產(chǎn)生負(fù)數(shù)的解決方法
本篇文章是對PHP函數(shù)ip2long轉(zhuǎn)換IP時數(shù)值太大產(chǎn)生負(fù)數(shù)的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06