mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-11 03:51:25 +01:00
FIX: Update swiftmailer librairies
This commit is contained in:
@@ -45,7 +45,8 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
/**
|
||||
* Create a new PopBeforeSmtpPlugin for $host and $port.
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $host Hostname or IP. Literal IPv6 addresses should be
|
||||
* wrapped in square brackets.
|
||||
* @param int $port
|
||||
* @param string $crypto as "tls" or "ssl"
|
||||
*/
|
||||
@@ -59,8 +60,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
/**
|
||||
* Set a Pop3Connection to delegate to instead of connecting directly.
|
||||
*
|
||||
* @param Swift_Plugins_Pop_Pop3Connection $connection
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection)
|
||||
@@ -72,8 +71,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
/**
|
||||
* Bind this plugin to a specific SMTP transport instance.
|
||||
*
|
||||
* @param Swift_Transport
|
||||
*/
|
||||
public function bindSmtp(Swift_Transport $smtp)
|
||||
{
|
||||
@@ -135,16 +132,12 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
if (!isset($this->socket)) {
|
||||
if (!$socket = fsockopen(
|
||||
$this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)
|
||||
);
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr));
|
||||
}
|
||||
$this->socket = $socket;
|
||||
|
||||
if (false === $greeting = fgets($this->socket)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('Failed to connect to POP3 host [%s]', trim($greeting))
|
||||
);
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? '')));
|
||||
}
|
||||
|
||||
$this->assertOk($greeting);
|
||||
@@ -167,9 +160,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
} else {
|
||||
$this->command("QUIT\r\n");
|
||||
if (!fclose($this->socket)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('POP3 host [%s] connection could not be stopped', $this->host)
|
||||
);
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host));
|
||||
}
|
||||
$this->socket = null;
|
||||
}
|
||||
@@ -177,8 +168,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
/**
|
||||
* Invoked just before a Transport is started.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -216,15 +205,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
private function command($command)
|
||||
{
|
||||
if (!fwrite($this->socket, $command)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('Failed to write command [%s] to POP3 host', trim($command))
|
||||
);
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? '')));
|
||||
}
|
||||
|
||||
if (false === $response = fgets($this->socket)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('Failed to read from POP3 host after command [%s]', trim($command))
|
||||
);
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? '')));
|
||||
}
|
||||
|
||||
$this->assertOk($response);
|
||||
@@ -234,17 +219,15 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
private function assertOk($response)
|
||||
{
|
||||
if (substr($response, 0, 3) != '+OK') {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('POP3 command failed [%s]', trim($response))
|
||||
);
|
||||
if ('+OK' != substr($response, 0, 3)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? '')));
|
||||
}
|
||||
}
|
||||
|
||||
private function getHostString()
|
||||
{
|
||||
$host = $this->host;
|
||||
switch (strtolower($this->crypto)) {
|
||||
switch (strtolower($this->crypto ?? '')) {
|
||||
case 'ssl':
|
||||
$host = 'ssl://'.$host;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user