$this->write('MAIL FROM:<'.$mail->getFrom().'>');
$this->getSMTPStatus();
if ($this->statusCode != 250) {
+ $this->abort();
throw new SystemException($this->formatError("wrong from format '".$mail->getFrom()."'"));
}
$this->getSMTPStatus();
if ($this->statusCode != 250 && $this->statusCode != 251) {
if ($this->statusCode < 550) {
+ $this->abort();
throw new SystemException($this->formatError("wrong recipient format '".$recipient."'"));
}
continue;
$recipientCounter++;
}
if (!$recipientCounter) {
- $this->write("RSET");
+ $this->abort();
return;
}
$this->write("DATA");
$this->getSMTPStatus();
if ($this->statusCode != 354 && $this->statusCode != 250) {
+ $this->abort();
throw new SystemException($this->formatError("smtp error"));
}
$this->getSMTPStatus();
if ($this->statusCode != 250) {
+ $this->abort();
throw new SystemException($this->formatError("message sending failed"));
}
}
return $result;
}
+ /**
+ * Aborts the current process. This is needed in case a new mail should be
+ * sent after a exception has occured
+ */
+ protected function abort() {
+ $this->write("RSET");
+ $this->read(); // read response, but do not care about status here
+ }
+
/**
* Gets error code and message from a server message.
*