Home >Backend Development >PHP Tutorial >php实现统计邮件大小的方法_PHP

php实现统计邮件大小的方法_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 14:36:11939browse

统计用户收件箱所占空间有多少,先计算每封邮件的大小(标题+内容+附近),后总和;
1、计算附近大小;
2、计算标题和内容大小
3、总和求出单封邮件大小
案例:
复制代码 代码如下:
    $attach_size= 0;   
    if($attachmentid){  //获取附近的大小   
        $attach_data= attachdata($attachmentid);   
        if($attach_data){   
            foreach($attach_dataas$value) {   
                $attach_size+= $value['filesize'];   
            }   
        }   
    }   
    //获取标题和邮件内容的大小   
    $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;  //邮件总大小          
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn