Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

  • Jyxo_Beholder_Executor
  • Jyxo_Beholder_Result
  • Jyxo_Beholder_TestCase
  • Jyxo_Beholder_TestCase_FileSystem
  • Jyxo_Beholder_TestCase_HttpResponse
  • Jyxo_Beholder_TestCase_Imap
  • Jyxo_Beholder_TestCase_JsonRpc
  • Jyxo_Beholder_TestCase_Memcached
  • Jyxo_Beholder_TestCase_Mysql
  • Jyxo_Beholder_TestCase_Pgsql
  • Jyxo_Beholder_TestCase_PhpExtension
  • Jyxo_Beholder_TestCase_PhpVersion
  • Jyxo_Beholder_TestCase_PhpZend
  • Jyxo_Beholder_TestCase_Smtp
  • Jyxo_Beholder_TestCase_Webdav
  • Jyxo_Beholder_TestCase_XmlRpc
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * Jyxo PHP Library
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file license.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * https://github.com/jyxo/php/blob/master/license.txt
 12:  */
 13: 
 14: /**
 15:  * Tests SMTP server availability.
 16:  *
 17:  * @category Jyxo
 18:  * @package Jyxo_Beholder
 19:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 20:  * @license https://github.com/jyxo/php/blob/master/license.txt
 21:  * @author Jaroslav HanslĂ­k
 22:  */
 23: class Jyxo_Beholder_TestCase_Smtp extends Jyxo_Beholder_TestCase
 24: {
 25:     /**
 26:      * Hostname.
 27:      *
 28:      * @var string
 29:      */
 30:     private $host;
 31: 
 32:     /**
 33:      * Recipient.
 34:      *
 35:      * @var string
 36:      */
 37:     private $to;
 38: 
 39:     /**
 40:      * Sender.
 41:      *
 42:      * @var string
 43:      */
 44:     private $from;
 45: 
 46:     /**
 47:      * Timeout.
 48:      *
 49:      * @var integer
 50:      */
 51:     private $timeout;
 52: 
 53:     /**
 54:      * Constructor.
 55:      *
 56:      * @param string $description Test description
 57:      * @param string $host Hostname
 58:      * @param string $to Recipient
 59:      * @param string $from Sender
 60:      * @param integer $timeout Timeout
 61:      */
 62:     public function __construct($description, $host, $to, $from = '', $timeout = 2)
 63:     {
 64:         parent::__construct($description);
 65: 
 66:         $this->host = (string) $host;
 67:         $this->to = (string) $to;
 68:         $this->from = (string) $from;
 69:         $this->timeout = (int) $timeout;
 70: 
 71:         // Default sender
 72:         if (empty($this->from)) {
 73:             $this->from = 'beholder@jyxo.com';
 74:         }
 75:     }
 76: 
 77:     /**
 78:      * Performs the test.
 79:      *
 80:      * @return Jyxo_Beholder_Result
 81:      */
 82:     public function run()
 83:     {
 84:         // The Jyxo_Mail_Sender_Smtp class is required
 85:         if (!class_exists('Jyxo_Mail_Sender_Smtp')) {
 86:             return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::NOT_APPLICABLE, 'Class Jyxo_Mail_Sender_Smtp missing');
 87:         }
 88: 
 89:         try {
 90:             $header = 'From: ' . $this->from . "\n";
 91:             $header .= 'To: ' . $this->to . "\n";
 92:             $header .= 'Subject: Beholder' . "\n";
 93:             $header .= 'Date: ' . date(DATE_RFC822) . "\n";
 94: 
 95:             $smtp = new Jyxo_Mail_Sender_Smtp($this->host, 25, $this->host, $this->timeout);
 96:             $smtp->connect()
 97:                 ->from($this->from)
 98:                 ->recipient($this->to)
 99:                 ->data($header, 'Beholder SMTP Test')
100:                 ->disconnect();
101:         } catch (Exception $e) {
102:             $smtp->disconnect();
103:             return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::FAILURE, sprintf('Send error %s', $this->host));
104:         }
105: 
106:         // OK
107:         return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::SUCCESS, $this->host);
108:     }
109: }
110: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0