PHP Classes

SaveBody on a busy server with large attachments

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  SaveBody on a busy server with large...  >  (Un) Subscribe thread alerts  
Subject:SaveBody on a busy server with large...
Summary:Shouldn't the temporary "BodyFile" files have unique names?
Messages:2
Author:Klemen
Date:2009-08-13 10:59:53
Update:2009-08-13 21:21:28
 

  1. SaveBody on a busy server with large...   Reply   Report abuse  
Picture of Klemen Klemen - 2009-08-13 10:59:53
Dear Manuel,

First of all thanks for such a powerful MIME parser, it has proved most useful to me and I tried many others found on PHPClasses.

I do have one concern and would like to hear your thoughts: with the "SaveBody" set to 1 the bodies are stored in a temporary folder with names "1", "2", "3", etc... The file names are stored in "BodyFile" variable. This all works great.

My concer is, on a busy server processing many e-mails with large attachments wouldn't it be possible that two or more e-mail are being parsed on the same time? For example one e-mail starts parsing then a few miliseconds later another e-mail starts parsing (by another thread), before the first one finishes. Wouldn't the second e-mail files overwrite the first one because they have the same names, before the first one could finish (it could take few seconds to parse and move large files)?

Wouldn't it be beter to give temporary files unique names? For example instead of "1", "2" and "3" they could have a random string in front, like "k4ur2tz_1", "k4ur2tz_2", "k4ur2tz_3", etc.

I am just thinking, didn't have such problems yet.

Thanks,
Klemen

  2. Re: SaveBody on a busy server with large...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-08-13 21:21:28 - In reply to message 1 from Klemen
Yes, but it is recommended that you create a directory of your own with a unique name for each message that you parse. Than set the SaveBody parameter the full path of that directory.

After you are done, you are recommended to clean up all files and the directory to avoid keeping filling your disk with files no longer in use.