Skip to content

Commit

Permalink
Add support for imap_open parameters (fix #62, #65)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jan 4, 2015
1 parent 4e7a798 commit c699d78
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* An IMAP server
*
*/
class Server
{
Expand All @@ -30,22 +29,34 @@ class Server
*/
protected $connection;

/**
* @var array
*/
protected $parameters;

/**
* Constructor
*
* @param string $hostname Internet domain name or bracketed IP address of server
* @param int $port TCP port number
* @param string $flags Optional flags
* @param string $hostname Internet domain name or bracketed IP address
* of server
* @param int $port TCP port number
* @param string $flags Optional flags
* @param array $parameters Connection parameters
*/
public function __construct($hostname, $port = 993, $flags = '/imap/ssl/validate-cert')
{
public function __construct(
$hostname,
$port = 993,
$flags = '/imap/ssl/validate-cert',
$parameters = array()
) {
if (!function_exists('\imap_open')) {
throw new \RuntimeException('IMAP extension must be enabled');
}

$this->hostname = $hostname;
$this->port = $port;
$this->flags = $flags ? '/' . ltrim($flags, '/') : '';
$this->parameters = $parameters;
}

/**
Expand All @@ -59,7 +70,14 @@ public function __construct($hostname, $port = 993, $flags = '/imap/ssl/validate
*/
public function authenticate($username, $password)
{
$resource = @\imap_open($this->getServerString(), $username, $password, null, 1);
$resource = @\imap_open(
$this->getServerString(),
$username,
$password,
null,
1,
$this->parameters
);

if (false === $resource) {
throw new AuthenticationFailedException($username);
Expand Down

0 comments on commit c699d78

Please sign in to comment.