]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - vendor/pear/mail/tests/smtp_error.phpt
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / pear / mail / tests / smtp_error.phpt
1 --TEST--
2 Mail: SMTP Error Reporting
3 --SKIPIF--
4 <?php
5
6 require_once 'PEAR/Registry.php';
7 $registry = new PEAR_Registry();
8
9 if (!$registry->packageExists('Net_SMTP')) die("skip\n");
10 --FILE--
11 <?php
12 require_once 'Mail.php';
13
14 /* Reference a bogus SMTP server address to guarantee a connection failure. */
15 $params = array('host' => 'bogus.host.tld');
16
17 /* Create our SMTP-based mailer object. */
18 $mailer = Mail::factory('smtp', $params);
19
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)) {
25         echo "OK";
26      }
27 }
28
29 --EXPECT--
30 OK