Skip to content

Commit

Permalink
Use new support for stream options on SMTP connect, add tests for it
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed May 16, 2013
1 parent 9cbce11 commit 85136af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,12 +1059,13 @@ protected function SmtpSend($header, $body) {
/**
* 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;
}
Expand Down Expand Up @@ -1092,7 +1093,7 @@ public function SmtpConnect() {
$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;
Expand Down
3 changes: 3 additions & 0 deletions test/phpmailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,9 @@ function test_SmtpConnect()
$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');
}

/**
Expand Down

0 comments on commit 85136af

Please sign in to comment.