php實(shí)現(xiàn)統(tǒng)計(jì)郵件大小的方法
統(tǒng)計(jì)用戶收件箱所占空間有多少,先計(jì)算每封郵件的大小(標(biāo)題+內(nèi)容+附近),后總和;
1、計(jì)算附近大小;
2、計(jì)算標(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)文章
延長(zhǎng)phpmyadmin登錄時(shí)間的方法
新安裝的phpmyadmin默認(rèn)是cookie模式,如果閑置十幾分鐘不操作的話,就會(huì)要求重新登錄。2011-02-02
php實(shí)現(xiàn)圖片文件與下載文件防盜鏈的方法
這篇文章主要介紹了php實(shí)現(xiàn)圖片文件與下載文件防盜鏈的方法,包括了常用的操作方法與服務(wù)器端配置方法等,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-11-11
php基于mcrypt_encrypt和mcrypt_decrypt實(shí)現(xiàn)字符串加密解密的方法
這篇文章主要介紹了php基于mcrypt_encrypt和mcrypt_decrypt實(shí)現(xiàn)字符串加密解密的方法,結(jié)合實(shí)例形式分析了mcrypt_encrypt和mcrypt_decrypt函數(shù)進(jìn)行加密、解密的相關(guān)使用技巧,需要的朋友可以參考下2016-07-07
探討PHP函數(shù)ip2long轉(zhuǎn)換IP時(shí)數(shù)值太大產(chǎn)生負(fù)數(shù)的解決方法
本篇文章是對(duì)PHP函數(shù)ip2long轉(zhuǎn)換IP時(shí)數(shù)值太大產(chǎn)生負(fù)數(shù)的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

