39 'host' =>
'localhost',
56 parent::__construct($buf, $dispatcher);
69 $this->_params[
'host'] = $host;
81 return $this->_params[
'host'];
93 $this->_params[
'port'] = (int) $port;
105 return $this->_params[
'port'];
117 $this->_params[
'timeout'] = (int) $timeout;
118 $this->_buffer->setParam(
'timeout', (
int) $timeout);
130 return $this->_params[
'timeout'];
142 if (
'tls' == $encryption) {
143 $this->_params[
'protocol'] =
'tcp';
144 $this->_params[
'tls'] =
true;
146 $this->_params[
'protocol'] = $encryption;
147 $this->_params[
'tls'] =
false;
160 return $this->_params[
'tls'] ?
'tls' : $this->_params[
'protocol'];
172 $this->_params[
'sourceIp'] = $source;
184 return isset($this->_params[
'sourceIp']) ? $this->_params[
'sourceIp'] : null;
197 foreach ($handlers as $handler) {
198 $assoc[$handler->getHandledKeyword()] = $handler;
200 uasort($assoc, array($this,
'_sortHandlers'));
201 $this->_handlers = $assoc;
214 return array_values($this->_handlers);
231 $failures = (array) $failures;
236 $this, $command, $codes, $failures, $stopSignal
243 return parent::executeCommand($command, $codes, $failures);
251 foreach ($this->_handlers as $handler) {
252 if (in_array(strtolower($method),
253 array_map(
'strtolower', (array) $handler->exposeMixinMethods())
255 $return = call_user_func_array(array($handler, $method), $args);
257 if (is_null($return) && substr($method, 0, 3) ==
'set') {
264 trigger_error(
'Call to undefined method '.$method, E_USER_ERROR);
278 sprintf(
"EHLO %s\r\n", $this->_domain), array(250)
281 return parent::_doHeloCommand();
284 if ($this->_params[
'tls']) {
288 if (!$this->_buffer->startTLS()) {
294 sprintf(
"EHLO %s\r\n", $this->_domain), array(250)
297 return parent::_doHeloCommand();
307 $handler->afterEhlo($this);
316 foreach ($handlers as $handler) {
317 $params = array_merge($params, (array) $handler->getMailParams());
319 $paramStr = !empty($params) ?
' '.implode(
' ', $params) :
'';
321 sprintf(
"MAIL FROM:<%s>%s\r\n", $address, $paramStr), array(250)
330 foreach ($handlers as $handler) {
331 $params = array_merge($params, (array) $handler->getRcptParams());
333 $paramStr = !empty($params) ?
' '.implode(
' ', $params) :
'';
335 sprintf(
"RCPT TO:<%s>%s\r\n", $address, $paramStr), array(250, 251, 252)
342 $capabilities = array();
343 $ehloResponse = trim($ehloResponse);
344 $lines = explode(
"\r\n", $ehloResponse);
346 foreach ($lines as $line) {
347 if (preg_match(
'/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) {
348 $keyword = strtoupper($matches[1]);
349 $paramStr = strtoupper(ltrim($matches[2],
' ='));
350 $params = !empty($paramStr) ? explode(
' ', $paramStr) : array();
351 $capabilities[$keyword] = $params;
355 return $capabilities;
361 foreach ($this->_handlers as $keyword => $handler) {
362 if (array_key_exists($keyword, $this->_capabilities)) {
363 $handler->setKeywordParams($this->_capabilities[$keyword]);
372 foreach ($this->_handlers as $keyword => $handler) {
373 if (array_key_exists($keyword, $this->_capabilities)) {
374 $handlers[] = $handler;
384 return $a->getPriorityOver($b->getHandledKeyword());