composer package updates
[openemr.git] / vendor / zendframework / zend-mail / src / Transport / SmtpOptions.php
blobf37bb693f04f276b66c0c5fc83f2bed277978c7d
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-mail for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-mail/blob/master/LICENSE.md New BSD License
6 */
8 namespace Zend\Mail\Transport;
10 use Zend\Mail\Exception;
11 use Zend\Stdlib\AbstractOptions;
13 class SmtpOptions extends AbstractOptions
15 /**
16 * @var string Local client hostname
18 protected $name = 'localhost';
20 /**
21 * @var string
23 protected $connectionClass = 'smtp';
25 /**
26 * Connection configuration (passed to the underlying Protocol class)
28 * @var array
30 protected $connectionConfig = [];
32 /**
33 * @var string Remote SMTP hostname or IP
35 protected $host = '127.0.0.1';
37 /**
38 * @var int
40 protected $port = 25;
42 /**
43 * The timeout in seconds for the SMTP connection
44 * (Use null to disable it)
46 * @var int|null
48 protected $connectionTimeLimit;
50 /**
51 * Return the local client hostname
53 * @return string
55 public function getName()
57 return $this->name;
60 /**
61 * Set the local client hostname or IP
63 * @todo hostname/IP validation
64 * @param string $name
65 * @throws \Zend\Mail\Exception\InvalidArgumentException
66 * @return SmtpOptions
68 public function setName($name)
70 if (! is_string($name) && $name !== null) {
71 throw new Exception\InvalidArgumentException(sprintf(
72 'Name must be a string or null; argument of type "%s" provided',
73 (is_object($name) ? get_class($name) : gettype($name))
74 ));
76 $this->name = $name;
77 return $this;
80 /**
81 * Get connection class
83 * This should be either the class Zend\Mail\Protocol\Smtp or a class
84 * extending it -- typically a class in the Zend\Mail\Protocol\Smtp\Auth
85 * namespace.
87 * @return string
89 public function getConnectionClass()
91 return $this->connectionClass;
94 /**
95 * Set connection class
97 * @param string $connectionClass the value to be set
98 * @throws \Zend\Mail\Exception\InvalidArgumentException
99 * @return SmtpOptions
101 public function setConnectionClass($connectionClass)
103 if (! is_string($connectionClass) && $connectionClass !== null) {
104 throw new Exception\InvalidArgumentException(sprintf(
105 'Connection class must be a string or null; argument of type "%s" provided',
106 (is_object($connectionClass) ? get_class($connectionClass) : gettype($connectionClass))
109 $this->connectionClass = $connectionClass;
110 return $this;
114 * Get connection configuration array
116 * @return array
118 public function getConnectionConfig()
120 return $this->connectionConfig;
124 * Set connection configuration array
126 * @param array $connectionConfig
127 * @return SmtpOptions
129 public function setConnectionConfig(array $connectionConfig)
131 $this->connectionConfig = $connectionConfig;
132 return $this;
136 * Get the host name
138 * @return string
140 public function getHost()
142 return $this->host;
146 * Set the SMTP host
148 * @todo hostname/IP validation
149 * @param string $host
150 * @return SmtpOptions
152 public function setHost($host)
154 $this->host = (string) $host;
155 return $this;
159 * Get the port the SMTP server runs on
161 * @return int
163 public function getPort()
165 return $this->port;
169 * Set the port the SMTP server runs on
171 * @param int $port
172 * @throws \Zend\Mail\Exception\InvalidArgumentException
173 * @return SmtpOptions
175 public function setPort($port)
177 $port = (int) $port;
178 if ($port < 1) {
179 throw new Exception\InvalidArgumentException(sprintf(
180 'Port must be greater than 1; received "%d"',
181 $port
184 $this->port = $port;
185 return $this;
189 * @return int|null
191 public function getConnectionTimeLimit()
193 return $this->connectionTimeLimit;
197 * @param int|null $seconds
198 * @return self
200 public function setConnectionTimeLimit($seconds)
202 $this->connectionTimeLimit = $seconds === null
203 ? null
204 : (int) $seconds;
206 return $this;