Hello,
I am attempting to send an error_log() message to my email. I don't see any mistakes - yet it is not sending the email.... Any ideas? -
<?php #Script 6.2
-
-
//Flag variable for site status:
-
-
$live = TRUE; // Test output switching status from TRUE; to FALSE;
-
-
//Email error
-
-
$email='odisey@odisey.com';
-
-
-
// Create the error handler
-
-
function my_error_handler($e_number, $e_message, $e_file, $e_line, $e_vars) {
-
-
global $live, $email;
-
-
//Build the error message
-
-
$message = "An error occurred in script '$e_file' on line $e_line: $e_message\n";
-
-
//Append $e_vars to the $message
-
-
$message .= print_r($e_vars, 1);
-
-
if ($live) {//Don't show the error
-
-
error_log($message, 1, $email); //Sends email
-
-
echo '<div class="error">A system error occurred. We apologize for the inconvenience. An email has been sent to administrator!</div><br />';
-
} else { //Development (Print the error)
-
-
echo '<div class="error">' . $message . '</div><br />';
-
}
-
-
} //End of my error handler() definition
-
-
//Use my error handler
-
-
set_error_handler ('my_error_handler');
-
?>
-
4 3431
Changed the title to better reflect the thread contents.
I don't see a mail() call in there anywhere. Where's the code that sends the email?
Is it not sending the email... or are you just not receiving it? PHP's mail() function only returns an error if it fails to send the email. If you're trying to send an email from your computer, try sending it to yourusername@localhost (if you're running a *n?x system), then open up a terminal window and type 'mail'.
Changed the title to better reflect the thread contents.
I don't see a mail() call in there anywhere. Where's the code that sends the email?
OK - I am just learning here. I added a mail() with the error $msg attached and it worked. The original code I got from the book though is as above. I was under the impression that the error_log() function would act as the mail() function in this case and send the email to $email.
Is that true?
OK - I am just learning here. I added a mail() with the error $msg attached and it worked. The original code I got from the book though is as above. I was under the impression that the error_log() function would act as the mail() function in this case and send the email to $email.
Is that true?
According to the documentation, error log is supposed to send email. I am not sure why your original code did not work. Perhaps the scope of the error_log's email function is restricted to the scope of the machine it is running on, as most *nix OSs have a locally handled email subsystem.
Regardless, I am glad it is working for you now. Welcome to The Scripts.
According to the documentation, error log is supposed to send email. I am not sure why your original code did not work. Perhaps the scope of the error_log's email function is restricted to the scope of the machine it is running on, as most *nix OSs have a locally handled email subsystem.
Regardless, I am glad it is working for you now. Welcome to The Scripts.
UPDATE: I have PHP 5 - MySQL 5 Apache/1.3.33 Server. I tested mail() and it sent the $msg. Then I reverted to error_log() and it sent the message.
...???...
Not sure what happened. It takes 5 - 10 mins to get the message from the server, but it sends.
THX - I will enjoy sharing ideas and helping out.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wayno |
last post by:
Hoping someone can help me out with this problem. First problem, is I
am unable to view my php error log. In my php.ini I have my log in
/var/www/logs/php_error_log. However, it has remained empty....
|
by: Google Mike |
last post by:
I've got RH9 Linux with default PHP.
Is there a way to send email on Linux to an Exchange Server from PHP
and/or other tools when there is *NOT* SMTP access?
Has anyone figured out a way to...
|
by: David Burson |
last post by:
Hi,
I have a VB.NET windows app that needs to automatically send a simple text
email when my users run a new version of the app for the first time. I
thought this would be simple, but after...
|
by: Erwin Moller |
last post by:
Hi Group,
I cannot log errors for some reason.
Situation: PHP 5.0 ISAPI on W2000 IIS 5.0
In php.ini:
error_reporting = E_ALL
log_errors = On
|
by: supz |
last post by:
Hi,
I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.
I'm using my...
|
by: mydejamail |
last post by:
My PHP setup is not updating the error_log, I have checked all the
error logging related settings and they have all been set.
The script is also crashing inexplicably. Whenever I call a specific...
|
by: Pseudonyme |
last post by:
Dear All :
Ever had an httpd error_log bigger than the httpd access log ?
We are using Linux-Apache-Fedora-Httpd 2006 configuration.
The PHP lines code that lead too tons of errors are :
...
|
by: August Karlstrom |
last post by:
Hi,
I'm looking for a function that *returns* a human readable string
representation of an array rather than prints it so I can use it with
the error_log procedure. Any clues?
August
|
by: beary |
last post by:
Using php 5
I have access to my own php.ini file on the server
I want to send any and all php errors to an email address
I tried changing the line error_log = error_log to
error_log = ("PHP...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |