Page 1 of 1

seding mail during die along with text output

Posted: Tue Feb 22, 2011 12:41 pm
by bcyork
Is it possible to send an email during a die function along with the text output to the user. I have a script that I use for clients to download files to hide the directory structure to get to them. However out of human error or a weird email client that messes up the link users won't get directed to the file. In the script there is a check for that. If the file doesn't exist then it goes to die and spits out a message. Is it possible to send me an email notifying me?

Thanks!
Brian

Re: seding mail during die along with text output

Posted: Tue Feb 22, 2011 2:39 pm
by AbraCadaver
Sure, post some code.

Re: seding mail during die along with text output

Posted: Wed Feb 23, 2011 10:47 am
by bcyork

Code: Select all

if(!file_exists($file)) die("The file doesn't seem to exist.");
Is it possible to put in the die () an aditional php script to send an email along with the message?

Re: seding mail during die along with text output

Posted: Wed Feb 23, 2011 10:57 am
by AbraCadaver
bcyork wrote:

Code: Select all

if(!file_exists($file)) die("The file doesn't seem to exist.");
Is it possible to put in the die () an aditional php script to send an email along with the message?
Just put it in the if:

Code: Select all

if(!file_exists($file)) {
   mail('me@example.com', 'file not found', $file . ' was not found, blah, blah');
   die("The file doesn't seem to exist.");
}

Re: seding mail during die along with text output

Posted: Wed Feb 23, 2011 11:04 am
by bcyork
Thanks!