Technical Discussion
  >> Web Design / HTML / Web hosting Forum


Register (or login) on our website and you will not see this ad.


These posts have been archived and can no longer be replied to or modified.
  Print Thread
Standard User KR1
(experienced) Wed 26-Jul-06 14:08:04
Print Post

PHP, detect problem with mail()?


[link to this post]
 
Does anyone know if it it possible to trap errors/warnings returned by mail() in PHP4? At the moment the following text is displayed at the top of my web page which does not look very good?

Warning: mail(): Failed to connect to mailserver at "broken.smtp.test" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

TIA
Standard User deleted
(deleted) Wed 26-Jul-06 14:41:13
Print Post

Re: PHP, detect problem with mail()?


[re: KR1] [link to this post]
 
You could suppress the error by prefixing your call with an @ symbol.

$result = @mail(...,...)

As this is a production site you really ought to change your php.ini file to log errors to a file and turn off errors in the output stream (see http://uk2.php.net/manual/en/ref.errorfunc.php). This means that your users will not get errors they don't understand and cannot fix while you have a single point of reference to see what problems have occured with your code.

Edited by deleted (Wed 26-Jul-06 18:16:38)

Standard User KR1
(experienced) Wed 26-Jul-06 16:59:11
Print Post

Re: PHP, detect problem with mail()?


[re: deleted] [link to this post]
 
Thanks just what I needed - in case anyone else is reading remove the ). at the end of the link to make it work.


Register (or login) on our website and you will not see this ad.

  Print Thread

Jump to