Skip to content

Commit

Permalink
Merge pull request #13 from ashnazg/bug20513
Browse files Browse the repository at this point in the history
Bug #20513: Mail_smtp::send() doesn't close socket for smtp connection [patch by e79ene]
  • Loading branch information
ashnazg authored Apr 11, 2017
2 parents 323726a + 8291878 commit 355bd96
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Mail/smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ public function __destruct()
* failure.
*/
public function send($recipients, $headers, $body)
{
$result = $this->send_or_fail($recipients, $headers, $body);

/* If persistent connections are disabled, destroy our SMTP object. */
if ($this->persist === false) {
$this->disconnect();
}

return $result;
}

protected function send_or_fail($recipients, $headers, $body)
{
/* If we don't already have an SMTP object, create one. */
$result = $this->getSMTPObject();
Expand Down Expand Up @@ -332,11 +344,6 @@ public function send($recipients, $headers, $body)
return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
}

/* If persistent connections are disabled, destroy our SMTP object. */
if ($this->persist === false) {
$this->disconnect();
}

return true;
}

Expand Down

0 comments on commit 355bd96

Please sign in to comment.