From 85136af8b63d7b48f5c23e9b85730529eadc2db3 Mon Sep 17 00:00:00 2001 From: Synchro Date: Thu, 16 May 2013 11:44:09 +0200 Subject: [PATCH] Use new support for stream options on SMTP connect, add tests for it --- class.phpmailer.php | 5 +++-- test/phpmailerTest.php | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index c2626b07..f77e7650 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -1059,12 +1059,13 @@ class PHPMailer { /** * Initiates a connection to an SMTP server. * Returns false if the operation failed. + * @param array $options An array of options compatible with stream_context_create() * @uses SMTP * @access public * @throws phpmailerException * @return bool */ - public function SmtpConnect() { + public function SmtpConnect($options = array()) { if(is_null($this->smtp)) { $this->smtp = new SMTP; } @@ -1092,7 +1093,7 @@ class PHPMailer { $host = $hostinfo[1]; $port = $hostinfo[2]; } - if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { + if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout, $options)) { try { if ($this->Helo) { $hello = $this->Helo; diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php index 910720b1..ea41294e 100644 --- a/test/phpmailerTest.php +++ b/test/phpmailerTest.php @@ -967,6 +967,9 @@ EOT; $this->Mail->SmtpClose(); $this->Mail->Host = "localhost:12345;10.10.10.10:54321;".$_REQUEST['mail_host']; $this->assertTrue($this->Mail->SmtpConnect(), 'SMTP multi-connect failed'); + $this->Mail->SmtpClose(); + $this->Mail->Host = $_REQUEST['mail_host']; + $this->assertTrue($this->Mail->SmtpConnect(array('socket' => array('bindto' => '0:7000'))), 'SMTP connect with options failed'); } /**