54 $this->_eventDispatcher = $dispatcher;
55 $this->_buffer = $buf;
69 $this->_domain = $domain;
90 if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this))
92 $this->_eventDispatcher->dispatchEvent($evt,
'beforeTransportStarted');
93 if ($evt->bubbleCancelled())
112 $this->_eventDispatcher->dispatchEvent($evt,
'transportStarted');
115 $this->_started =
true;
142 $failedRecipients = (array) $failedRecipients;
147 'Cannot send message without a sender address'
151 if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
153 $this->_eventDispatcher->dispatchEvent($evt,
'beforeSendPerformed');
154 if ($evt->bubbleCancelled())
160 $to = (array) $message->
getTo();
161 $cc = (array) $message->
getCc();
162 $bcc = (array) $message->
getBcc();
164 $message->
setBcc(array());
168 $sent += $this->
_sendTo($message, $reversePath, $to, $failedRecipients);
169 $sent += $this->
_sendCc($message, $reversePath, $cc, $failedRecipients);
170 $sent += $this->
_sendBcc($message, $reversePath, $bcc, $failedRecipients);
182 if ($sent == count($to) + count($cc) + count($bcc))
194 $evt->setFailedRecipients($failedRecipients);
195 $this->_eventDispatcher->dispatchEvent($evt,
'sendPerformed');
210 if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this))
212 $this->_eventDispatcher->dispatchEvent($evt,
'beforeTransportStopped');
213 if ($evt->bubbleCancelled())
227 $this->_buffer->terminate();
231 $this->_eventDispatcher->dispatchEvent($evt,
'transportStopped');
239 $this->_started =
false;
249 $this->_eventDispatcher->bindEventListener($plugin);
283 $failures = (array) $failures;
284 $seq = $this->_buffer->write($command);
286 if ($evt = $this->_eventDispatcher->createCommandEvent($this, $command, $codes))
288 $this->_eventDispatcher->dispatchEvent($evt,
'commandSent');
306 sprintf(
"HELO %s\r\n", $this->_domain), array(250)
314 sprintf(
"MAIL FROM: <%s>\r\n", $address), array(250)
322 sprintf(
"RCPT TO: <%s>\r\n", $address), array(250, 251, 252)
335 $this->_buffer->setWriteTranslations(array(
"\r\n." =>
"\r\n.."));
339 $this->_buffer->flushBuffers();
345 $this->_buffer->setWriteTranslations(array());
364 $path = key($sender);
377 if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e))
379 $this->_eventDispatcher->dispatchEvent($evt,
'exceptionThrown');
380 if (!$evt->bubbleCancelled())
394 list($code, $separator, $text) = sscanf($response,
'%3d%[ -]%s');
395 $valid = (empty($wanted) || in_array($code, $wanted));
397 if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response,
400 $this->_eventDispatcher->dispatchEvent($evt,
'responseReceived');
407 'Expected response code ' . implode(
'/', $wanted) .
' but got code ' .
408 '"' . $code .
'", with message "' . $response .
'"'
422 $line = $this->_buffer->readLine($seq);
425 while (null !== $line &&
false !== $line &&
' ' != $line{3});
438 array $recipients, array &$failedRecipients)
442 foreach ($recipients as $forwardPath)
451 $failedRecipients[] = $forwardPath;
470 array $to, array &$failedRecipients)
482 array $cc, array &$failedRecipients)
494 array $bcc, array &$failedRecipients)
497 foreach ($bcc as $forwardPath => $name)
499 $message->
setBcc(array($forwardPath => $name));
501 $message, $reversePath, array($forwardPath), $failedRecipients
510 if (!empty($_SERVER[
'SERVER_NAME'])
511 && $this->
_isFqdn($_SERVER[
'SERVER_NAME']))
513 $this->_domain = $_SERVER[
'SERVER_NAME'];
515 elseif (!empty($_SERVER[
'SERVER_ADDR']))
517 $this->_domain = sprintf(
'[%s]', $_SERVER[
'SERVER_ADDR']);
525 if (
false !== $dotPos = strpos($hostname,
'.'))
527 return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1);