Horde_Smtp::__construct PHP Méthode

__construct() public méthode

Constructor.
public __construct ( array $params = [] )
$params array Configuration parameters: - chunk_size: (integer) If CHUNKING is supported on the server, the chunk size (in octets) to send. 0 will disable chunking. @since 1.7.0 - context: (array) Any context parameters passed to stream_create_context(). @since 1.9.0 - debug: (string) If set, will output debug information to the stream provided. The value can be any PHP supported wrapper that can be opened via fopen(). DEFAULT: No debug output - host: (string) The SMTP server. DEFAULT: localhost - localhost: (string) The hostname of the localhost. (since 1.9.0) DEFAULT: Auto-determined. - password: (mixed) The SMTP password or a Horde_Smtp_Password object (since 1.1.0). DEFAULT: NONE - port: (string) The SMTP port. DEFAULT: 587 (See RFC 6409/STD 72) - secure: (string) Use SSL or TLS to connect. DEFAULT: true (use 'tls' option, if available) - false (No encryption) - 'ssl' (Auto-detect SSL version) - 'sslv2' (Force SSL version 2) - 'sslv3' (Force SSL version 3) - 'tls' (TLS; started via protocol-level negotation over unencrypted channel; RECOMMENDED way of initiating secure connection) - 'tlsv1' (TLS direct version 1.x connection to server) [@since 1.3.0] - true (Use TLS, if available) [@since 1.2.0] - timeout: (integer) Connection timeout, in seconds. DEFAULT: 30 seconds - username: (string) The SMTP username. DEFAULT: NONE - xoauth2_token: (string) If set, will authenticate via the XOAUTH2 mechanism (if available) with this token. Either a string or a Horde_Smtp_Password object (since 1.1.0).
    public function __construct(array $params = array())
    {
        // Default values.
        $params = array_merge(array('chunk_size' => self::CHUNK_DEFAULT, 'context' => array(), 'host' => 'localhost', 'port' => 587, 'secure' => true, 'timeout' => 30), array_filter($params));
        foreach ($params as $key => $val) {
            $this->setParam($key, $val);
        }
        $this->_initOb();
    }

Usage Example

Exemple #1
0
 /**
  */
 public function __construct(array $params = array())
 {
     // LMTP MUST NOT be on port 25 (RFC 2033 [5]).
     if (isset($params['port']) && $params['port'] == 25) {
         throw new InvalidArgumentException('Cannot use port 25 for a LMTP server.');
     }
     parent::__construct($params);
 }