mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-61921 admin: Support XOAUTH2 for outgoing mail
- Loading branch information
Showing
6 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@core @core_admin | ||
Feature: Outgoing mail configuration | ||
In order to send email from Moodle | ||
As a Moodle administrator | ||
I need to set mail configuration | ||
|
||
Background: | ||
Given I log in as "admin" | ||
|
||
Scenario: SMTP Auth Type without OAuth 2 Service setup yet | ||
Given I navigate to "Server > Email > Outgoing mail configuration" in site administration | ||
And I should not see "XOAUTH2" in the "SMTP Auth Type" "select" | ||
And I should see "LOGIN" in the "SMTP Auth Type" "select" | ||
And I should see "PLAIN" in the "SMTP Auth Type" "select" | ||
|
||
Scenario: SMTP Auth Type with OAuth 2 Service setup | ||
Given I navigate to "Server > OAuth 2 services" in site administration | ||
And I press "Google" | ||
And I should see "Create new service: Google" | ||
And I set the following fields to these values: | ||
| Name | Testing service | | ||
| Client ID | thisistheclientid | | ||
| Client secret | supersecret | | ||
And I press "Save changes" | ||
When I navigate to "Server > Email > Outgoing mail configuration" in site administration | ||
Then I should see "XOAUTH2" in the "SMTP Auth Type" "select" | ||
And I should see "LOGIN" in the "SMTP Auth Type" "select" | ||
And I should see "PLAIN" in the "SMTP Auth Type" "select" | ||
And I should see "Testing service" in the "OAuth 2 Service" "select" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Moodle Customised version of the PHPMailer OAuth class | ||
* | ||
* @package core | ||
* @copyright 2022 Huong Nguyen <huongnv13@gmail.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class moodle_phpmailer_oauth extends \PHPMailer\PHPMailer\OAuth { | ||
|
||
protected function getToken() { | ||
return $this->provider->get_accesstoken()->token; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters