I have a script which sends file to end user: <?
...
header('length, type...')
readfile('file-to-download.dat');
//the following script should be executed after the whole file downloaded completely.
mail('my@email.com', 'Download completed', 'body', 'from: my@email.com');
?>
It works without any problem. The readfile function shows the "File download" dialog of IE and I won't receive email until IE downloaded the whole file.
However, I found that I need to use session in this script, so I added session_start() at the beginning of this it:
<?
session_start()
...
?>
And suddenly, as long as I execute this script, without finishing the download, I can receive the email message immediately. Why this happened? Is there a way to solve this problem?