5

When mail() fails, there not much info about what went wrong. I understand that the best course of action is to check your sendmail logs, or whatever mailer has PHP used. But from a programming and pragmatic, point of view: on a Linux hosted environment, what can a PHP program do to get as much extra info to properly log the failure, probable cause etc and produce an usable, actionable error?

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • I have never been able to successfully retrieve error information. The only way that I have found to mitigate this is via a queuing system within my php applications, where the queue will simply keep attempting to send the email. – Josiah Jul 16 '09 at 00:34

2 Answers2

2

The problem is that, on a Unix-like system, PHP just hands the entire thing to a command-line utility that really only gives PHP the ability to say 'yay' or 'nay'. To do what you want, you'd want to use something like PEAR's Net_SMTP, which can actually communicate intelligently with the mail server.

TML
  • 12,813
  • 3
  • 38
  • 45
0

There's surely going to be a better answer than this, but I'd be interested in hearing it too. Perhaps one solution is to write your own version of the mail() function. Its not toooo hard. And if you really need full/detailed info on why sending of the message failed then it might not be a bad idea. It'll certainly give you more control.

Dave Archer
  • 3,022
  • 20
  • 23
  • On a shared hosted environment I doubt I'll be able to load an external PHP module. But the main problem is that I really, really have more important issues to address first :) – Remus Rusanu Jul 16 '09 at 00:36