I am attempting to track and record information in a specific php file used where I work. The file is not my own work originally; I inherited it from my predecessor in the position. I am somewhat familiar with PHP, but not an expert. Additionally, I am still a newcomer to Linux work, and the file in question is running on the Suse 9 distribution.

I have modified the file with a simple check at the end to mark certain predefined limits for my tracking purposes. When the file's output goes past these limits, the file is supposed to email me, letting me know what has happened.

I know about the mail() function; I found out about it shortly after I began working on this program. The problem is, it doesn't seem to want to work for me. I am not sure that this is a php problem; the php mail() call always returns a true for me when I test it. However, I have tested microvariations on the mail call (mostly differing echo statements so I'll know it has processed correctly), but have not yet received any of the messages I have been attempting to send myself. Considering I've sent about three dozen by now, over the course of a ~3hr span, I suspect something is happening to prevent them from reaching the internet and being sent.

Does anyone know of any reason that the information sent by the mail function might not be going anywhere?

I recognize, since I am constantly getting 'true' results, that this might not be a php problem. If it is not; if this sounds like it might be a problem with the OS instead, I respectfully request that this message be moved to the correct forum.

Thanks in advance,
-EnderX

Recommended Answers

All 5 Replies

I had the same problem once, I could never get the mail() function to work. Turn out after a few hours I thought about checking my spam filter, and seeing all the emails that had actually worked but were caught at my ISP. A definite DUH for me, I now always check it.

And if thats not your case, and the server is local to you, try and send the mail to yourself@localhost and see if maybe network problems are causing it not to send or filters stopping it. You can also check the php.ini file for sendmail settings. Maybe they are wrong

StatiX

Thank you for your advice. I'll look into that. I suspect it's not the spam filters, though; I've tried sending to both my work account and my personal account and neither one got through.

What should the settings in php.ini look like? I'd like to make sure of those asap.

I don't have a unix box handy, just windows but this is what you would need to look at:
*****************************************

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "C:\Program Files\xampp\sendmail\sendmail.exe -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

This is an excert from a win32 php.in file
What you will need to check is the path to sendmail, make sure it is correct. Some Servers use other software besides sendmail to send mail, if so you need the correct path to the mail program. Usually a program will act as though it is sendmail and you need not worry with it.

Note that this file is from a win 32 machine and will not work on unix

StatiX

Running on Unix, so the windows-based code didn't help much. I tried to id the location of our sendmail program, since it's mentioned in the commented out stuff, but no such luck; still didn't want to work.

Any other suggestions for what might be going wrong?

Never mind, I found a workaround. I was able to modify an older perl script to send out the message for me, and I never had any problem writing the php-driven data to a file, simply to the mail server. Thanks for the assistance, though! I really appreciated it.

-EnderX

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.