diff --git a/README.md b/README.md index ad8c724a..3e9abd5d 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ senders using the `-s` option. For instance, to simultaneously use the console, file, and server senders, you would input: ```bash -vendor/bin/trap -s console -s file -s server +vendor/bin/trap -sconsole -sfile -sserver ``` ## Contributing diff --git a/composer.json b/composer.json index ef78a3d0..75251e5d 100644 --- a/composer.json +++ b/composer.json @@ -119,7 +119,7 @@ "@putenv XDEBUG_MODE=coverage", "roave-infection-static-analysis-plugin --ansi --configuration=infection.json.dist --logger-github --ignore-msi-with-no-mutations --only-covered" ], - "psalm": "psalm --show-info=true", + "psalm": "psalm", "psalm:baseline": "psalm --set-baseline=psalm-baseline.xml", "psalm:ci": "psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "refactor": "rector process --config=rector.php", diff --git a/src/Command/Test.php b/src/Command/Test.php index a9429ebf..6e886a98 100644 --- a/src/Command/Test.php +++ b/src/Command/Test.php @@ -35,8 +35,9 @@ protected function execute( ): int { $this->logger = new Logger($output); - // XHProf - $this->sendContent('yii-xhprof.http'); + $this->mail2($output, true); + // $this->sendContent('yii-xhprof.http'); + die; $this->dump(); \usleep(100_000); @@ -59,6 +60,17 @@ private function dump(): void $_SERVER['VAR_DUMPER_FORMAT'] = 'server'; $_SERVER['VAR_DUMPER_SERVER'] = "$this->addr:$this->port"; + trap( + index: \substr(\file_get_contents(__FILE__), 0, 312), + )->code( + syntax: 'php', + // editable: true, + // decorated: 'twitter', + // theme: 'dark', + ); + + trap(fuck: true); + trap(['foo' => 'bar']); trap(123); trap(new \DateTimeImmutable()); @@ -94,6 +106,36 @@ private function dump(): void } } + private function mail2(OutputInterface $output, bool $multipart = false): void + { + try { + $socket = \socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + \socket_connect($socket, $this->addr, $this->port); + + $this->sendMailPackage($output, $socket, '', '220 '); + $this->sendMailPackage($output, $socket, "HELO\r\n", '250 '); + $this->sendMailPackage($output, $socket, "MAIL FROM: \r\n", '250 '); + $this->sendMailPackage($output, $socket, "RCPT TO: \r\n", '250 '); + $this->sendMailPackage($output, $socket, "RCPT TO: \r\n", '250 '); + $this->sendMailPackage($output, $socket, "DATA\r\n", '354 '); + + $this->sendMailPackage( + $output, + $socket, + \file_get_contents(Info::TRAP_ROOT . '/resources/payloads/yii-mail.http'), + '250 ', + ); + + // End of data + $this->sendMailPackage($output, $socket, "QUIT\r\n", '221 '); + + \socket_close($socket); + + } catch (\Throwable $e) { + $this->logger->exception($e, 'Mail protocol error', important: true); + } + } + private function mail(OutputInterface $output, bool $multipart = false): void { try { @@ -141,7 +183,26 @@ private function mail(OutputInterface $output, bool $multipart = false): void $this->sendMailPackage( $output, $socket, - "

This is what displays in most modern email clients

\r\n", + '' + . "

This is what displays in most modern email clients

\r\n", + '', + ); + $this->sendMailPackage($output, $socket, "\r\n", ''); + $this->sendMailPackage($output, $socket, "--boundary-string--\r\n", ''); + // Image + $this->sendMailPackage( + $output, + $socket, + "Content-Type: image/png; name=4486bda9ad8b1f422deaf6a750194668@trap\r\n", + '', + ); + $this->sendMailPackage($output, $socket, "Content-Transfer-Encoding: base64\r\n", ''); + $this->sendMailPackage($output, $socket, "Content-Disposition: inline; name=\"4486bda9ad8b1f422deaf6a750194668@trap\"; filename=logo-embeddable\r\n", ''); + $this->sendMailPackage($output, $socket, "\r\n", ''); + $this->sendMailPackage( + $output, + $socket, + \base64_encode(\file_get_contents(Info::TRAP_ROOT . '/resources/payloads/logo.png')) . "\r\n", '', ); $this->sendMailPackage($output, $socket, "\r\n", '');