mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
Improve SMTP (see smtp_mail()) - treat unexpected SMTP replies, incomplete writes, and failed TLS negotiation as delivery failures. Refs #1128 thanks @TrapoSAMA
37 lines
932 B
PHP
37 lines
932 B
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SmtpTest extends TestCase
|
|
{
|
|
public function testRequireResponseAcceptsExpectedCode(): void
|
|
{
|
|
$stream = fopen('php://memory', 'r+');
|
|
fwrite($stream, "220 ready\r\n");
|
|
rewind($stream);
|
|
|
|
smtp_require_response($stream, 220);
|
|
$this->assertTrue(true);
|
|
fclose($stream);
|
|
}
|
|
|
|
public function testRequireResponseRejectsUnexpectedCode(): void
|
|
{
|
|
$stream = fopen('php://memory', 'r+');
|
|
fwrite($stream, "550 rejected\r\n");
|
|
rewind($stream);
|
|
|
|
$this->expectException(RuntimeException::class);
|
|
smtp_require_response($stream, 250);
|
|
}
|
|
|
|
public function testSmtpWriteRejectsClosedStream(): void
|
|
{
|
|
$stream = fopen('php://memory', 'r+');
|
|
fclose($stream);
|
|
|
|
$this->expectException(RuntimeException::class);
|
|
smtp_write($stream, "EHLO example.com\r\n");
|
|
}
|
|
}
|