title: How can I catch an error caused by mail()?
body: <p>Does anyone know how can I catch a mail error (error is displayed while sending email and the error is caused by the mailserver down) in php?</p>
  
  <p>Error that was caused by emailserver down is below:</p>
  
  <blockquote>
    <p>&lt;!--2010-02-24T14:26:43+11:00 NOTICE (5): Unexpected Error: mail() [&lt;a href='function.mail'&gt;function.mail&lt;/a&gt;]: Failed to connect to mailserver at &quot;ip &quot; port portip, verify your &quot;SMTP&quot; and &quot;smtp_port&quot; setting in php.ini or use ini_set() (# 2).<br>
    2010-02-24 14:26:43<br>
    Username: admin<br>
    Error in line 439 of file D:\test.php<br>
    Script: /customer.php<br>
     [Global Error Handler]<br>
    --&gt;</p>
  </blockquote>