The following describes how to use php to calculate the Mail size. For more information about how much space your inbox occupies, see, calculate the size of each email (title + content + nearby), and then sum;
1. calculate the nearby size;
2. calculate the title and content size
3. calculate the total size of a single email.
Case:
The code is as follows:
$ Attach_size = 0;
If ($ attachmentid) {// Obtain the nearby size
$ Attach_data = attachdata ($ attachmentid );
If ($ attach_data ){
Foreach ($ attach_dataas $ value ){
$ Attach_size + = $ value ['filesize'];
}
}
}
// Obtain the title and email content size
$ 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 mail size
?>