2 Mail: SMTP Error Reporting
6 require_once 'PEAR/Registry.php';
7 $registry = new PEAR_Registry();
9 if (!$registry->packageExists('Net_SMTP')) die("skip\n");
12 require_once 'Mail.php';
14 /* Reference a bogus SMTP server address to guarantee a connection failure. */
15 $params = array('host' => 'bogus.host.tld');
17 /* Create our SMTP-based mailer object. */
18 $mailer = Mail::factory('smtp', $params);
20 /* Attempt to send an empty message in order to trigger an error. */
21 $e = $mailer->send(array(), array(), '');
22 if (is_a($e, 'PEAR_Error')) {
23 $err = $e->getMessage();
24 if (preg_match('/Failed to connect to bogus.host.tld:25 \[SMTP: Failed to connect socket:.*/i', $err)) {