3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Mail\Transport
;
12 use Zend\Mail\Exception
;
13 use Zend\Stdlib\AbstractOptions
;
15 class SmtpOptions
extends AbstractOptions
18 * @var string Local client hostname
20 protected $name = 'localhost';
25 protected $connectionClass = 'smtp';
28 * Connection configuration (passed to the underlying Protocol class)
32 protected $connectionConfig = array();
35 * @var string Remote SMTP hostname or IP
37 protected $host = '127.0.0.1';
45 * Return the local client hostname
49 public function getName()
55 * Set the local client hostname or IP
57 * @todo hostname/IP validation
59 * @throws \Zend\Mail\Exception\InvalidArgumentException
62 public function setName($name)
64 if (!is_string($name) && $name !== null) {
65 throw new Exception\
InvalidArgumentException(sprintf(
66 'Name must be a string or null; argument of type "%s" provided',
67 (is_object($name) ?
get_class($name) : gettype($name))
75 * Get connection class
77 * This should be either the class Zend\Mail\Protocol\Smtp or a class
78 * extending it -- typically a class in the Zend\Mail\Protocol\Smtp\Auth
83 public function getConnectionClass()
85 return $this->connectionClass
;
89 * Set connection class
91 * @param string $connectionClass the value to be set
92 * @throws \Zend\Mail\Exception\InvalidArgumentException
95 public function setConnectionClass($connectionClass)
97 if (!is_string($connectionClass) && $connectionClass !== null) {
98 throw new Exception\
InvalidArgumentException(sprintf(
99 'Connection class must be a string or null; argument of type "%s" provided',
100 (is_object($connectionClass) ?
get_class($connectionClass) : gettype($connectionClass))
103 $this->connectionClass
= $connectionClass;
108 * Get connection configuration array
112 public function getConnectionConfig()
114 return $this->connectionConfig
;
118 * Set connection configuration array
120 * @param array $connectionConfig
121 * @return SmtpOptions
123 public function setConnectionConfig(array $connectionConfig)
125 $this->connectionConfig
= $connectionConfig;
134 public function getHost()
142 * @todo hostname/IP validation
143 * @param string $host
144 * @return SmtpOptions
146 public function setHost($host)
148 $this->host
= (string) $host;
153 * Get the port the SMTP server runs on
157 public function getPort()
163 * Set the port the SMTP server runs on
166 * @throws \Zend\Mail\Exception\InvalidArgumentException
167 * @return SmtpOptions
169 public function setPort($port)
173 throw new Exception\
InvalidArgumentException(sprintf(
174 'Port must be greater than 1; received "%d"',