Skip to content

Commit

Permalink
Catch InvalidArgumentException from Zend Mail Header. #16
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFox committed Sep 9, 2018
1 parent 7f512e2 commit f9751dd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use RuntimeException;
use PHPUnit_Framework_MockObject_MockObject;
use TheFox\Network\AbstractSocket;
use Zend\Mail\Header\Exception\InvalidArgumentException;
use Zend\Mail\Message;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Psr\Log\NullLogger;
Expand Down Expand Up @@ -468,7 +469,11 @@ public function handleMessage(string $msgRaw): string
if ($msgRaw == '.') {
$this->mail = substr($this->mail, 0, -strlen(static::MSG_SEPARATOR));

$zmail = Message::fromString($this->mail);
try {
$zmail = Message::fromString($this->mail);
} catch (InvalidArgumentException $e) {
return $this->sendSyntaxErrorInParameters();
}

$server = $this->getServer();
$server->newMail($this->from, $this->rcpt, $zmail);
Expand Down Expand Up @@ -633,6 +638,14 @@ private function sendCommandNotImplemented(): string
return $this->dataSend('502 Command not implemented');
}

/**
* @return string
*/
private function sendBadSequenceOrAuth(): string
{
return $this->dataSend('503 Bad sequence of commands');
}

/**
* @return string
*/
Expand Down

0 comments on commit f9751dd

Please sign in to comment.