PHP implementation of Statistical message size method _php
Source: Internet
Author: User
Count the amount of space the user Inbox, first calculate the size of each message (title + content + nearby), after the sum;
1, calculate the nearby size;
2. Calculate title and content size
3, sum to find a single message size
Case: Copy the Code code as follows:
$attach _size= 0;
if ($attachmentid) {//Get the size nearby
$attach _data= Attachdata ($attachmentid);
if ($attach _data) {
foreach ($attach _dataas$value) {
$attach _size+= $value [' filesize '];
}
}
}
Get the title and the size of the message content
$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; Total message size
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service