mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-20 01:52:15 +02:00
Merge pull request #2814 from czirkoszoltan/avoid-error-message-when-could-not-connect
Avoid POP3 client error message when TCP connection failed
This commit is contained in:
commit
a5bc7ddba9
@ -337,6 +337,11 @@ class POP3
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
// If could not connect at all, no need to disconnect
|
||||
if ($this->pop_conn === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sendString('QUIT' . static::LE);
|
||||
|
||||
// RFC 1939 shows POP3 server sending a +OK response to the QUIT command.
|
||||
|
@ -42,7 +42,7 @@ final class PopBeforeSmtpTest extends TestCase
|
||||
* Set up default include path.
|
||||
* Default to the dir above the test dir, i.e. the project home dir.
|
||||
*/
|
||||
define('PHPMAILER_INCLUDE_DIR', dirname(__DIR__));
|
||||
define('PHPMAILER_INCLUDE_DIR', dirname(dirname(__DIR__)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,10 @@ final class PopBeforeSmtpTest extends TestCase
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
$this->markTestSkipped('This test needs a non-Windows OS to run');
|
||||
}
|
||||
|
||||
// Chdir to test directory as runfakepopserver.sh runs fakepopserver.sh
|
||||
// from its working directory.
|
||||
chdir(PHPMAILER_INCLUDE_DIR . "/test");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,4 +124,16 @@ final class PopBeforeSmtpTest extends TestCase
|
||||
@shell_exec('kill -TERM ' . escapeshellarg($pid));
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case when POP3 server is unreachable.
|
||||
*/
|
||||
public function testPopBeforeSmtpUnreachable()
|
||||
{
|
||||
// There is no POP3 server at all. Port is different again.
|
||||
self::assertFalse(
|
||||
POP3::popBeforeSmtp('localhost', 1102, 10, 'user', 'xxx'),
|
||||
'POP before SMTP should have failed'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -123,4 +123,4 @@ while [ ${BREAK} -eq 0 ] ; do
|
||||
fi
|
||||
done
|
||||
|
||||
echo "+OK Bye!\r\n"
|
||||
echo -en "+OK Bye!\r\n"
|
||||
|
Loading…
Reference in New Issue
Block a user