diff --git a/.env.example b/.env.example index bdcd2c334..8db3fac6e 100644 --- a/.env.example +++ b/.env.example @@ -172,6 +172,14 @@ OUTLOOK_AUTH_URI=https://login.live.com/oauth20_authorize.srf OUTLOOK_TOKEN_URI=https://login.live.com/oauth20_token.srf OUTLOOK_REFRESH_URI=https://login.live.com/oauth20_token.srf +#office365 +OFFICE365_CLIENT_ID= +OFFICE365_CLIENT_SECRET= +OFFICE365_CLIENT_URI=http://localhost/?page=home +OFFICE365_AUTH_URI=https://login.live.com/oauth20_authorize.srf +OFFICE365_TOKEN_URI=https://login.live.com/oauth20_token.srf +OFFICE365_REFRESH_URI=https://login.live.com/oauth20_token.srf + #ldap.php LDAP_SERVER=localhost LDAP_ENABLE_TLS=true diff --git a/config/oauth2.php b/config/oauth2.php index 35c391280..21f5a812c 100644 --- a/config/oauth2.php +++ b/config/oauth2.php @@ -39,4 +39,14 @@ 'token_uri' => env('OUTLOOK_TOKEN_URI', 'https://login.live.com/oauth20_token.srf'), 'refresh_uri' => env('OUTLOOK_REFRESH_URI', 'https://login.live.com/oauth20_token.srf') ], + + //[office365] + 'office365' => [ + 'client_id' => env('OFFICE365_CLIENT_ID', ''), + 'client_secret' => env('OFFICE365_CLIENT_SECRET', ''), + 'client_uri' => env('OFFICE365_CLIENT_URI', 'http://localhost/?page=home'), + 'auth_uri' => env('OFFICE365_AUTH_URI', 'https://login.live.com/oauth20_authorize.srf'), + 'token_uri' => env('OFFICE365_TOKEN_URI', 'https://login.live.com/oauth20_token.srf'), + 'refresh_uri' => env('OFFICE365_REFRESH_URI', 'https://login.live.com/oauth20_token.srf') + ], ]; diff --git a/modules/core/functions.php b/modules/core/functions.php index bea403918..d4bc8f80b 100644 --- a/modules/core/functions.php +++ b/modules/core/functions.php @@ -255,6 +255,7 @@ function get_oauth2_data($config) { return [ 'gmail' => $config->get('gmail',[]), 'outlook' => $config->get('outlook',[]), + 'office365' => $config->get('office365',[]), ]; }} diff --git a/modules/imap/functions.php b/modules/imap/functions.php index 24d6048a1..fd5935eb4 100644 --- a/modules/imap/functions.php +++ b/modules/imap/functions.php @@ -853,6 +853,9 @@ function imap_refresh_oauth2_token($server, $config) { elseif ($server['server'] == 'imap-mail.outlook.com') { $details = $oauth2_data['outlook']; } + elseif ($server['server'] == 'imap-mail.office365.com') { + $details = $oauth2_data['office365']; + } if (!empty($details)) { $oauth2 = new Hm_Oauth2($details['client_id'], $details['client_secret'], $details['client_uri']); $result = $oauth2->refresh_token($details['refresh_uri'], $server['refresh_token']); diff --git a/modules/imap/hm-imap.php b/modules/imap/hm-imap.php index fbb8dbaa8..f609698d7 100644 --- a/modules/imap/hm-imap.php +++ b/modules/imap/hm-imap.php @@ -320,7 +320,6 @@ public function authenticate($username, $password) { } return $authed; } - /** * attempt starttls diff --git a/modules/nux/services.php b/modules/nux/services.php index 39c97d0d9..c17ca633d 100644 --- a/modules/nux/services.php +++ b/modules/nux/services.php @@ -62,9 +62,9 @@ 'name' => 'Office365', 'scope' => 'wl.imap', 'smtp' => array( - 'server' => 'outlook.office365.com', + 'server' => 'smtp.office365.com', 'port' => 587, - 'tls'=> 'yes' + 'tls'=> false ) )); diff --git a/modules/sievefilters/modules.php b/modules/sievefilters/modules.php index 8949e994d..16454fa50 100644 --- a/modules/sievefilters/modules.php +++ b/modules/sievefilters/modules.php @@ -1292,7 +1292,6 @@ function sieve_enabled_callback($val) { return $val; } class Hm_Output_enable_sieve_filter_setting extends Hm_Output_Module { protected function output() { $settings = $this->get('user_settings'); - // exit(var_dump($settings['enable_sieve_filter'])); if ((array_key_exists('enable_sieve_filter', $settings) && $settings['enable_sieve_filter']) || DEFAULT_ENABLE_SIEVE_FILTER) { $checked = ' checked="checked"'; $reset = ''; diff --git a/tests/phpunit/modules/core/functions.php b/tests/phpunit/modules/core/functions.php index 818cf4018..a358f3f1f 100644 --- a/tests/phpunit/modules/core/functions.php +++ b/tests/phpunit/modules/core/functions.php @@ -84,7 +84,7 @@ public function test_is_email_address() { */ public function test_get_oauth2_data() { $mock_config = new Hm_Mock_Config(); - $this->assertEquals(array('gmail' => [],'outlook' => []), (get_oauth2_data($mock_config))); + $this->assertEquals(array('gmail' => [],'outlook' => [],'office365' => []), (get_oauth2_data($mock_config))); } /** * @preserveGlobalState disabled