Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ public function checkPassword($uid, $password) {
$groups[] = $pieces[1];
}

$protocol = ($this->sslmode === "ssl") ? "imaps" : "imap";
$url = "{$protocol}://{$this->mailbox}:{$this->port}";
$ch = curl_init();
if ($this->sslmode === 'tls') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a simpler solution: how about just changing this line to include everything expect:

  • explicit ssl (and also TRUE),
  • explicit nossl, notls, maybe "empty string" (and also FALSE)
    so everything else (including tls) would be handled as STARTTLS...
    what do you think?

curl_setopt($ch, CURLOPT_USE_SSL, CURLUSESSL_ALL);

if ($this->sslmode !== 'tls') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't people with tls set use STARTTLS by default? - this would exclude them, right?

$protocol = 'imaps';
// Use STARTTLS as default encryption mode
if ($this->sslmode) {
curl_setopt($ch, CURLOPT_USE_SSL, CURLUSESSL_ALL);
}
} else {
$protocol = 'imaps';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you set the $protocol two times to imaps but for starttls (and insecure connections) we would need imap, right?

}

$url = "{$protocol}://{$this->mailbox}:{$this->port}";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
Expand Down