@@ -172,6 +172,9 @@ |
||
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | + /** |
|
| 176 | + * @param integer $code |
|
| 177 | + */ |
|
| 175 | 178 | protected function sendReply($code, $message, $close = false) |
| 176 | 179 | { |
| 177 | 180 | $out = ''; |
@@ -2,11 +2,9 @@ |
||
| 2 | 2 | namespace SamIT\React\Smtp; |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -use React\Dns\Query\TimeoutException; |
|
| 6 | 5 | use React\EventLoop\LoopInterface; |
| 7 | 6 | use React\EventLoop\Timer\TimerInterface; |
| 8 | 7 | use React\Socket\ConnectionInterface; |
| 9 | -use React\Stream\WritableStream; |
|
| 10 | 8 | |
| 11 | 9 | class Connection extends \React\Socket\Connection{ |
| 12 | 10 | const STATUS_NEW = 0; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use React\Socket\ConnectionInterface; |
| 9 | 9 | use React\Stream\WritableStream; |
| 10 | 10 | |
| 11 | -class Connection extends \React\Socket\Connection{ |
|
| 11 | +class Connection extends \React\Socket\Connection { |
|
| 12 | 12 | const STATUS_NEW = 0; |
| 13 | 13 | const STATUS_INIT = 1; |
| 14 | 14 | const STATUS_FROM = 2; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->reset(self::STATUS_NEW); |
| 141 | 141 | $this->on('line', [$this, 'handleCommand']); |
| 142 | 142 | if ($this->bannerDelay > 0) { |
| 143 | - $loop->addTimer($this->bannerDelay, function () use ($disconnect) { |
|
| 143 | + $loop->addTimer($this->bannerDelay, function() use ($disconnect) { |
|
| 144 | 144 | $this->sendReply(220, $this->banner); |
| 145 | 145 | $this->removeListener('data', $disconnect); |
| 146 | 146 | }); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | // Socket is raw, not using fread as it's interceptable by filters |
| 160 | 160 | // See issues #192, #209, and #240 |
| 161 | - $data = stream_socket_recvfrom($stream, $this->bufferSize);; |
|
| 161 | + $data = stream_socket_recvfrom($stream, $this->bufferSize); ; |
|
| 162 | 162 | |
| 163 | 163 | $limit = $this->state == self::STATUS_BODY ? 1000 : 512; |
| 164 | 164 | if ('' !== $data && false !== $data) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $delimiter = "\r\n"; |
| 172 | - while(false !== $pos = strpos($this->lineBuffer, $delimiter)) { |
|
| 172 | + while (false !== $pos = strpos($this->lineBuffer, $delimiter)) { |
|
| 173 | 173 | $line = substr($this->lineBuffer, 0, $pos); |
| 174 | 174 | $this->lineBuffer = substr($this->lineBuffer, $pos + strlen($delimiter)); |
| 175 | 175 | $this->emit('line', [$line, $this]); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $out = ''; |
| 222 | 222 | if (is_array($message)) { |
| 223 | 223 | $last = array_pop($message); |
| 224 | - foreach($message as $line) { |
|
| 224 | + foreach ($message as $line) { |
|
| 225 | 225 | $out .= "$code-$line\r\n"; |
| 226 | 226 | } |
| 227 | 227 | $this->write($out); |
@@ -25,18 +25,21 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * This function will throw an exception since replacing headers is will mangle SMTP messages. |
| 27 | 27 | * @throws \Exception |
| 28 | + * @return \GuzzleHttp\Psr7\MessageTrait |
|
| 28 | 29 | */ |
| 29 | 30 | public function withHeader($name, $value); |
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * This function will throw an exception since removing headers is will mangle SMTP messages. |
| 33 | 34 | * @throws \Exception |
| 35 | + * @return \GuzzleHttp\Psr7\MessageTrait |
|
| 34 | 36 | */ |
| 35 | 37 | public function withoutHeader($name); |
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * This function will throw an exception since removing headers is will mangle SMTP messages. |
| 39 | 41 | * @throws \Exception |
| 42 | + * @return string |
|
| 40 | 43 | */ |
| 41 | 44 | public function getHeaderLine($name); |
| 42 | 45 | |
@@ -96,7 +99,6 @@ discard block |
||
| 96 | 99 | * new and/or updated header and value. |
| 97 | 100 | * |
| 98 | 101 | * @return self |
| 99 | - * @param array $recipients Array of email => name pairs. |
|
| 100 | 102 | * @throws \InvalidArgumentException for invalid email. |
| 101 | 103 | */ |
| 102 | 104 | public function withAddedRecipient($email, $name = null); |
@@ -11,6 +11,10 @@ |
||
| 11 | 11 | throw new \Exception('SMTP Message does not support replacing headers.'); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | + /** |
|
| 15 | + * @param string $name |
|
| 16 | + * @param string $value |
|
| 17 | + */ |
|
| 14 | 18 | public function withAddedHeader($name, $value) |
| 15 | 19 | { |
| 16 | 20 | $new = clone $this; |
@@ -57,12 +57,12 @@ |
||
| 57 | 57 | return $this->withRecipients([$email => $name]); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function withRecipients(array $recipients) |
|
| 61 | - { |
|
| 62 | - $new = clone $this; |
|
| 63 | - $new->recipients = $recipients; |
|
| 64 | - return $new; |
|
| 65 | - } |
|
| 60 | + public function withRecipients(array $recipients) |
|
| 61 | + { |
|
| 62 | + $new = clone $this; |
|
| 63 | + $new->recipients = $recipients; |
|
| 64 | + return $new; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public function withAddedRecipient($email, $name = null) |
| 68 | 68 | { |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $result = []; |
| 29 | 29 | $header = strtolower($header); |
| 30 | - foreach($this->headers as list($name, $value)) { |
|
| 30 | + foreach ($this->headers as list($name, $value)) { |
|
| 31 | 31 | if ($header == strtolower($name)) { |
| 32 | 32 | $result[] = [$name, $value]; |
| 33 | 33 | } |
@@ -38,7 +38,6 @@ |
||
| 38 | 38 | * new and/or updated header and value. |
| 39 | 39 | * |
| 40 | 40 | * @return self |
| 41 | - * @param array $recipients Array of email => name pairs. |
|
| 42 | 41 | * @throws \InvalidArgumentException for invalid email. |
| 43 | 42 | */ |
| 44 | 43 | public function withAddedRecipient($email, $name = null); |
@@ -2,11 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace SamIT\React\Smtp; |
| 4 | 4 | |
| 5 | -use Evenement\EventEmitter; |
|
| 6 | 5 | use React\EventLoop\LoopInterface; |
| 7 | -use React\Http\ServerInterface; |
|
| 8 | -use React\Socket\ServerInterface as SocketServerInterface; |
|
| 9 | -use React\Socket\ConnectionInterface; |
|
| 10 | 6 | |
| 11 | 7 | /** @event request */ |
| 12 | 8 | class Server extends \React\Socket\Server |
@@ -3,5 +3,5 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Message implements MessageInterface |
| 5 | 5 | { |
| 6 | - use MessageTrait; |
|
| 6 | + use MessageTrait; |
|
| 7 | 7 | } |
| 8 | 8 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public function withAddedRecipients(array $recipients) |
| 28 | 28 | { |
| 29 | 29 | $new = clone $this; |
| 30 | - foreach($recipients as $email => $name) { |
|
| 30 | + foreach ($recipients as $email => $name) { |
|
| 31 | 31 | $this->validateEmail($email); |
| 32 | 32 | $new->recipients[$email] = $name; |
| 33 | 33 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function withRecipients(array $recipients) { |
| 47 | 47 | $new = clone $this; |
| 48 | 48 | $new->recipients = []; |
| 49 | - foreach($recipients as $email => $name) { |
|
| 49 | + foreach ($recipients as $email => $name) { |
|
| 50 | 50 | $this->validateEmail($email); |
| 51 | 51 | $new->recipients[$email] = $name; |
| 52 | 52 | } |