-
Notifications
You must be signed in to change notification settings - Fork 335
Filter mails with Sieve #1822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter mails with Sieve #1822
Changes from all commits
21a5cba
6d7b0dc
bc7c457
e0d2677
efe41b3
04b9ada
ad68ce1
4b1ca97
a6e052f
5500191
5e30083
e24a7ea
cb22a01
9b293ef
87f6a86
4c6731c
ffce2bf
0d02f87
f154227
3fa328f
d430498
0ff3a4a
a38ad68
e75db36
129abc1
0e8b058
54522c3
4d38ce1
a914d10
960ccbf
eff785c
0e9b506
45891a2
51727e2
443b1e0
91dff6f
244f87d
32046e2
ea8101a
a3164b4
7396655
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
|
|
||
| namespace OCA\Mail; | ||
|
|
||
| use Horde\ManageSieve; | ||
| use Horde_Imap_Client_Mailbox; | ||
| use Horde_Imap_Client_Socket; | ||
| use Horde_Mail_Rfc822_List; | ||
|
|
@@ -55,7 +56,10 @@ class Account implements JsonSerializable { | |
| private $account; | ||
|
|
||
| /** @var Horde_Imap_Client_Socket */ | ||
| private $client; | ||
| private $imapClient; | ||
|
|
||
| /** @var ManageSieve */ | ||
| private $sieveClient; | ||
|
|
||
| /** @var ICrypto */ | ||
| private $crypto; | ||
|
|
@@ -114,9 +118,10 @@ public function getEMailAddress() { | |
|
|
||
| /** | ||
| * @return Horde_Imap_Client_Socket | ||
| * @throws \Horde_Imap_Client_Exception | ||
| */ | ||
| public function getImapConnection() { | ||
| if (is_null($this->client)) { | ||
| if (is_null($this->imapClient)) { | ||
| $host = $this->account->getInboundHost(); | ||
| $user = $this->account->getInboundUser(); | ||
| $password = $this->account->getInboundPassword(); | ||
|
|
@@ -144,10 +149,44 @@ public function getImapConnection() { | |
| ))]; | ||
| } | ||
| } | ||
| $this->client = new \Horde_Imap_Client_Socket($params); | ||
| $this->client->login(); | ||
| $this->imapClient = new \Horde_Imap_Client_Socket($params); | ||
| $this->imapClient->login(); | ||
| } | ||
| return $this->client; | ||
| return $this->imapClient; | ||
| } | ||
|
|
||
| /** | ||
| * @return ManageSieve | ||
| * @throws ManageSieve\Exception | ||
| */ | ||
| public function getSieveConnection() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| if ($this->sieveClient === null) { | ||
| $host = $this->account->getSieveHost(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $user = $this->account->getSieveUser(); | ||
| $password = $this->account->getSievePassword(); | ||
| $password = $this->crypto->decrypt($password); | ||
| $port = $this->account->getSievePort(); | ||
| $ssl_mode = $this->convertSslMode($this->account->getSieveSslMode()); | ||
|
|
||
| $params = [ | ||
| 'host' => $host, | ||
| 'port' => $port, | ||
| 'user' => $user, | ||
| 'password' => $password, | ||
| 'secure' => $ssl_mode, | ||
| ]; | ||
|
|
||
| // TODO: configure sieve logging | ||
| /*if ($this->config->getSystemValue('debug', false)) { | ||
| $params['logger'] = $this->config->getSystemValue('datadirectory') . '/horde_sieve.log'; | ||
| }*/ | ||
|
|
||
| $this->sieveClient = new ManageSieve($params); | ||
|
|
||
| } | ||
|
|
||
| return $this->sieveClient; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -201,6 +240,11 @@ public function testConnectivity(Horde_Mail_Transport $transport) { | |
| if ($transport instanceof Horde_Mail_Transport_Smtphorde) { | ||
| $transport->getSMTPObject(); | ||
| } | ||
|
|
||
| // connect to sieve | ||
| if ($this->account->getSieveHost() !== null) { | ||
| $this->getSieveConnection(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.