├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml └── workflows │ └── moodle-ci.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── classes ├── mailtest_form.php └── privacy │ └── provider.php ├── composer.json ├── composer.lock ├── index.php ├── lang └── en │ └── local_mailtest.php ├── locallib.php ├── phpcs.xml.dist ├── pix ├── icon.png └── logo.png ├── settings.php └── version.php /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Report an issue to help us improve this plugin. 3 | title: "Bug: " 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | ## Thank you for taking the time to fill out this bug report. 9 | Sorry to hear that you are experiencing an issue. In order to help us help you, please complete this form to the best of your ability. The more information you can provide, the easier it will be to for us to help you.
10 | ***In a hurry for support?*** Contact us directly for premium support and development at [TNG Consulting Inc.](https://www.tngconsulting.ca/contact). 11 | - type: checkboxes 12 | id: prerequisites 13 | attributes: 14 | label: Prerequisites 15 | description: Please answer the following questions before submitting an issue. 16 | options: 17 | - label: I'm reporting the issue to the correct repository. 18 | required: true 19 | - label: I am running the latest version of this plugin (if not, please upgrade first). 20 | required: true 21 | - label: I checked the [README.md](../blob/master/README.md) and [Wiki](../wiki) documentation but did not find my answer. 22 | required: true 23 | - label: I searched to make sure that this issue had not already been reported. 24 | required: true 25 | - label: I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site. 26 | - label: I am submitting no more than one bug report per issue ticket (please do not submit multiple bugs in one issue ticket). 27 | required: true 28 | - label: I understand that support is provided by volunteer(s). 29 | required: true 30 | - type: textarea 31 | id: issue 32 | attributes: 33 | label: What happened? 34 | description: A clear and concise description of what you think the bug is. 35 | validations: 36 | required: true 37 | - type: textarea 38 | id: expectation 39 | attributes: 40 | label: What do you think should have happened? 41 | description: Include a clear and concise description of what you expected to happen. 42 | value: I expected '...' 43 | validations: 44 | required: true 45 | - type: textarea 46 | id: steps-to-reproduce 47 | attributes: 48 | label: Steps to reproduce 49 | description: Please provide clearly ordered steps to reproduce the issue. 50 | value: | 51 | 1. Login as '...' (specify user role) 52 | 2. Go to '...' 53 | 3. Click on '....' 54 | 4. Scroll down to '....' 55 | 5. See error or issue. 56 | You get it? 57 | validations: 58 | required: true 59 | - type: textarea 60 | id: screenshots 61 | attributes: 62 | label: Screenshots 63 | description: If applicable, add screenshots. It really helps us understand your issue. 64 | - type: input 65 | id: moodle 66 | attributes: 67 | label: Moodle version 68 | placeholder: e.g. Moodle 4.4.0+ (Build 20240422) 69 | validations: 70 | required: true 71 | - type: checkboxes 72 | id: language 73 | attributes: 74 | label: Installed Moodle UI Language packs. 75 | description: You can find the Moodle version by navigating as a site administrator to **Site Administration > General or Site Administration (tab) > Notifications** and scrolling to the bottom of the page. 76 | options: 77 | - label: English only 78 | - label: One or more other languages/regional dialects (specify below) 79 | - label: Other 80 | validations: 81 | required: true 82 | - type: input 83 | id: other-language 84 | attributes: 85 | label: If other language(s), please specify 86 | - type: textarea 87 | id: workaround 88 | attributes: 89 | label: Workaround 90 | description: Are you currently able to work around this issue? If so, how? 91 | - type: textarea 92 | id: moreinfo 93 | attributes: 94 | label: Additional information 95 | description: Add any other information about the problem here. For example, other installed plugins, logs for example. If you know where the problem is in the source code, we would appreciated it if you would be so kind as to let us know. Even better, feel free to submit a pull request (PR) if you can. Problems that include solutions get fixed faster. 96 | - type: textarea 97 | id: sysinfo 98 | attributes: 99 | label: System information 100 | description: Depending on the issue, you may be asked to provide additional system information. 101 | value: | 102 | Client Device type: (e.g. Desktop, iPhone or iPad, Android phone or tablet, Other - specify) 103 | Client Operating System: (e.g. Windows, Linux, Mac OS, Android, iOS, Other - specify) 104 | Client Web Browser: (e.g. Chrome, Edge, Firefox, Safari, Safe Exam Browser, Moodle Mobile App) 105 | Server Operating System: (e.g. Windows, Linux, Mac OS, Other - specify) 106 | Server Webserver: (e.g. Apache, Nginx, IIS, Other - specify) 107 | Server PHP: (e.g. 7.4, 8.0, 8.1, 8.2, 8.3, Other - specify) 108 | - type: checkboxes 109 | attributes: 110 | label: Code of Conduct 111 | options: 112 | - label: I have read and agree to the project's code of conduct. 113 | required: true 114 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Premium Support 4 | about: In a hurry? Contact us for premium support and development. 5 | url: https://www.tngconsulting.ca/ 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Share your ideas for this project. 3 | title: "Feature Request: " 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | ## Thanks for taking the time to share your ideas and suggestions. 9 | We love hearing ideas and suggestions from people who use our plugins.
10 | ***In a hurry for this new feature?*** Contact us directly for premium development and support services at [TNG Consulting Inc.](https://www.tngconsulting.ca/contact). 11 | - type: checkboxes 12 | id: prerequisites 13 | attributes: 14 | label: Prerequisites 15 | description: Please answer the following questions before submitting a feature request. 16 | options: 17 | - label: I am requesting the new feature to the correct repository. 18 | required: true 19 | - label: I checked the latest version on GitHub and the [README.md](../blob/master/README.md) documentation to ensure that this functionality does not already exist. 20 | required: true 21 | - label: I searched to make sure that this feature has not already been requested. 22 | required: true 23 | - label: I have, or I know someone who has, the ability and willingness to test the new feature on a Moodle LMS-based site. 24 | - label: I agree to submit one feature request per issue ticket (do not submit multiple requests in one issue ticket). 25 | required: true 26 | - label: I understand that development and support is provided by volunteer(s) and that all final implementation decisions are up TNG Consulting Inc. 27 | required: true 28 | - type: textarea 29 | attributes: 30 | label: Feature Request - The User Story 31 | description: Provide a clear and concise description of the feature are you requesting or idea that you have. Be sure include one or more **real-life** examples of how you **will** use the new feature. Do not make up a story just because it is easier. We only implement new features if we understand your goal and it makes sense to us. 32 | placeholder: e.g. As a [Moodle role], I need/want to [...], so that [...]. 33 | validations: 34 | required: true 35 | - type: textarea 36 | attributes: 37 | label: Screenshots / Mock-ups 38 | description: Add any screenshots, videos or documentation which can help us visualize your vision. 39 | - type: textarea 40 | attributes: 41 | label: Alterative you have considered 42 | description: Provide a clear and concise description of any alternative solutions or features you've considered. If you have seen a similar feature in another plugin, please provide us with a link to it. 43 | - type: textarea 44 | attributes: 45 | label: Additional information 46 | - type: dropdown 47 | attributes: 48 | label: Planning on submitting a solution in a pull request (PR)? 49 | description: If so, we look forward to working with you to integrate your work. Feature requests with a provided solution may be integrated sooner. Be sure to read the [CONTRIBUTING] guidelines. 50 | options: 51 | - "Yes" 52 | - "No" 53 | - "Maybe" 54 | validations: 55 | required: true 56 | - type: checkboxes 57 | attributes: 58 | label: Code of Conduct 59 | options: 60 | - label: I have read and agree to the project's code of conduct. 61 | required: true 62 | -------------------------------------------------------------------------------- /.github/workflows/moodle-ci.yml: -------------------------------------------------------------------------------- 1 | # Runs tests and code analysis. 2 | # Based on: 3 | # https://github.com/moodlehq/moodle-plugin-ci/blob/main/gha.dist.yml 4 | 5 | # Title of the workflow 6 | name: Moodle Plugin CI 7 | 8 | # Run this workflow every time a new commit pushed to your repository or PR created. 9 | on: [push, pull_request] 10 | 11 | # Give just enough permissions to fetch code (actions/checkout). 12 | permissions: 13 | contents: read 14 | 15 | jobs: 16 | # Set the job key. The key is displayed as the job name when a job name is not provided 17 | test: 18 | # Virtual environment to use. 19 | runs-on: ubuntu-24.04 20 | 21 | # DB services you need for testing. 22 | services: 23 | postgres: 24 | image: postgres:14 25 | env: 26 | POSTGRES_USER: 'postgres' 27 | POSTGRES_HOST_AUTH_METHOD: 'trust' 28 | ports: 29 | - 5432:5432 30 | options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 31 | 32 | mariadb: 33 | image: mariadb:10.11.0 34 | env: 35 | MYSQL_USER: 'root' 36 | MYSQL_ALLOW_EMPTY_PASSWORD: "true" 37 | MYSQL_CHARACTER_SET_SERVER: "utf8mb4" 38 | MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" 39 | ports: 40 | - 3306:3306 41 | options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 42 | 43 | # Determines build matrix. This is a list of PHP versions, databases and 44 | # branches to test our project against. For each combination a separate 45 | # build will be created. For example below, builds will be created in 46 | # total (7.4-pgsql, 7.4-mariadb, 8.0-pgsql, 8.0-mariadb, etc.). 47 | strategy: 48 | fail-fast: false 49 | matrix: 50 | include: 51 | # Moodle 5.0.x (MOODLE_500_STABLE). 52 | - php: '8.4' 53 | moodle-branch: 'MOODLE_500_STABLE' 54 | database: 'mariadb' 55 | - php: '8.3' 56 | moodle-branch: 'MOODLE_500_STABLE' 57 | database: 'pgsql' 58 | - php: '8.2' 59 | moodle-branch: 'MOODLE_500_STABLE' 60 | database: 'mariadb' 61 | # Moodle 4.5.x (MOODLE_405_STABLE). 62 | - php: '8.3' 63 | moodle-branch: 'MOODLE_405_STABLE' 64 | database: 'pgsql' 65 | - php: '8.1' 66 | moodle-branch: 'MOODLE_405_STABLE' 67 | database: 'mariadb' 68 | # Moodle 4.4.x (MOODLE_404_STABLE). 69 | - php: '8.3' 70 | moodle-branch: 'MOODLE_404_STABLE' 71 | database: 'pgsql' 72 | - php: '8.1' 73 | moodle-branch: 'MOODLE_404_STABLE' 74 | database: 'mariadb' 75 | # Moodle 4.3.x (MOODLE_403_STABLE). 76 | - php: '8.2' 77 | moodle-branch: 'MOODLE_403_STABLE' 78 | database: 'pgsql' 79 | - php: '8.0' 80 | moodle-branch: 'MOODLE_403_STABLE' 81 | database: 'mariadb' 82 | # Moodle 4.2.x (MOODLE_402_STABLE). 83 | - php: '8.2' 84 | moodle-branch: 'MOODLE_402_STABLE' 85 | database: 'mariadb' 86 | - php: '8.0' 87 | moodle-branch: 'MOODLE_402_STABLE' 88 | database: 'pgsql' 89 | # Moodle 4.1.x (MOODLE_401_STABLE). 90 | - php: '8.1' 91 | moodle-branch: 'MOODLE_401_STABLE' 92 | database: 'pgsql' 93 | - php: '7.4' 94 | moodle-branch: 'MOODLE_401_STABLE' 95 | database: 'mariadb' 96 | 97 | steps: 98 | # Check out this repository code in ./plugin directory 99 | - name: Check out repository code 100 | uses: actions/checkout@v4 101 | with: 102 | path: plugin 103 | 104 | # Install PHP of required version. For possible options see https://github.com/shivammathur/setup-php 105 | - name: Setup PHP ${{ matrix.php }} 106 | uses: shivammathur/setup-php@v2 107 | with: 108 | php-version: ${{ matrix.php }} 109 | extensions: ${{ matrix.extensions }} 110 | ini-values: max_input_vars=6000 111 | # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". 112 | # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). 113 | coverage: pcov 114 | 115 | # Install this project into a directory called "ci", updating PATH and locale, define nvm location. 116 | - name: Initialise moodle-plugin-ci 117 | run: | 118 | composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 119 | echo $(cd ci/bin; pwd) >> $GITHUB_PATH 120 | echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH 121 | sudo locale-gen en_AU.UTF-8 122 | echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV 123 | 124 | # Run the default install. 125 | # Optionally, it is possible to specify a different Moodle repo to use 126 | # (https://github.com/moodle/moodle.git is used by default) and define 127 | # ignore directives or any other env vars for install step. For more 128 | # details on configuring for specific requirements please refer to the 129 | # 'Help' page. 130 | # 131 | # env: 132 | # MOODLE_REPO=https://github.com/username/moodle.git 133 | # IGNORE_PATHS: 'ignore' 134 | # IGNORE_NAMES: 'ignore_name.php' 135 | # MUSTACHE_IGNORE_NAMES: 'broken.mustache' 136 | # CODECHECKER_IGNORE_PATHS: 'ignoreme' 137 | # CODECHECKER_IGNORE_NAMES: 'ignoreme_name.php' 138 | # 139 | # Other env vars are available for install, namely: 140 | # - DB_USER / DB_PASS / DB_NAME / DB_HOST / DB_PORT: used 141 | # by install to feed the corresponding --db-xxxx options. 142 | # - MOODLE_APP: used to install dependencies to run Behat tests 143 | # using the Moodle App. 144 | - name: Install moodle-plugin-ci 145 | run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 146 | env: 147 | DB: ${{ matrix.database }} 148 | MOODLE_BRANCH: ${{ matrix.moodle-branch }} 149 | # Uncomment this to run Behat tests using the Moodle App. 150 | # MOODLE_APP: 'true' 151 | 152 | # Steps that are run for the purpose of testing. Any of these steps 153 | # can be re-ordered or removed to your liking. And of course, you can 154 | # add any of your own custom steps. 155 | - name: PHP Lint 156 | continue-on-error: true # This step will show errors but will not fail 157 | if: ${{ !cancelled() }} 158 | run: moodle-plugin-ci phplint 159 | 160 | - name: PHP Copy/Paste Detector 161 | continue-on-error: true # This step will show errors but will not fail 162 | if: ${{ !cancelled() }} 163 | run: moodle-plugin-ci phpcpd 164 | 165 | - name: PHP Mess Detector 166 | continue-on-error: true # This step will show errors but will not fail 167 | if: ${{ !cancelled() }} 168 | run: moodle-plugin-ci phpmd 169 | 170 | - name: Moodle Code Checker 171 | continue-on-error: true # This step will show errors but will not fail 172 | if: ${{ !cancelled() }} 173 | run: moodle-plugin-ci phpcs --max-warnings 0 174 | 175 | - name: Moodle PHPDoc Checker 176 | continue-on-error: true # This step will show errors but will not fail 177 | if: ${{ !cancelled() }} 178 | run: moodle-plugin-ci phpdoc --max-warnings 0 179 | 180 | - name: Validating 181 | continue-on-error: true # This step will show errors but will not fail 182 | if: ${{ !cancelled() }} 183 | run: moodle-plugin-ci validate 184 | 185 | - name: Check upgrade savepoints 186 | if: ${{ !cancelled() }} 187 | run: moodle-plugin-ci savepoints 188 | 189 | # This plugin does not use Mustache templates. 190 | # - name: Mustache Lint 191 | # if: ${{ !cancelled() }} 192 | # run: moodle-plugin-ci mustache 193 | 194 | - name: Grunt 195 | continue-on-error: true # This step will show errors but will not fail 196 | if: ${{ !cancelled() }} 197 | run: moodle-plugin-ci grunt --max-lint-warnings 0 198 | 199 | - name: PHPUnit tests 200 | continue-on-error: true # This step will show errors but will not fail 201 | if: ${{ !cancelled() }} 202 | run: moodle-plugin-ci phpunit --fail-on-warning 203 | 204 | # - name: Behat features 205 | # id: behat 206 | # if: ${{ !cancelled() }} 207 | # run: moodle-plugin-ci behat --profile chrome 208 | 209 | # This step allows to upload Behat faildump (screenshots) as workflow artifact 210 | # so it can be downloaded and inspected. You don't need this step if you 211 | # are not running Behat test. Artifact will be retained for 7 days. 212 | 213 | # - name: Upload Behat Faildump 214 | # if: ${{ failure() && steps.behat.outcome == 'failure' }} 215 | # uses: actions/upload-artifact@v4 216 | # with: 217 | # name: Behat Faildump (${{ join(matrix.*, ', ') }}) 218 | # path: ${{ github.workspace }}/moodledata/behat_dump 219 | # retention-days: 7 220 | # if-no-files-found: ignore 221 | 222 | - name: Mark cancelled jobs as failed. 223 | if: ${{ cancelled() }} 224 | run: exit 1 225 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ##### Only include English 2 | /lang/* 3 | !/lang/en 4 | 5 | ##### Windows 6 | # Windows thumbnail cache files 7 | Thumbs.db 8 | Thumbs.db:encryptable 9 | ehthumbs.db 10 | ehthumbs_vista.db 11 | 12 | # Dump file 13 | *.stackdump 14 | 15 | # Folder config file 16 | [Dd]esktop.ini 17 | 18 | # Recycle Bin used on file shares 19 | $RECYCLE.BIN/ 20 | 21 | # Windows Installer files 22 | # Windows Installer files 23 | *.cab 24 | *.msi 25 | *.msix 26 | *.msm 27 | *.msp 28 | 29 | # Windows shortcuts 30 | *.lnk 31 | 32 | ##### Linux 33 | *~ 34 | 35 | # temporary files which can be created if a process still has a handle open of a deleted file 36 | .fuse_hidden* 37 | 38 | # KDE directory preferences 39 | .directory 40 | 41 | # Linux trash folder which might appear on any partition or disk 42 | .Trash-* 43 | 44 | # .nfs files are created when an open file is removed but is still being accessed 45 | .nfs* 46 | 47 | ##### MacOS 48 | # General 49 | .DS_Store 50 | .AppleDouble 51 | .LSOverride 52 | 53 | # Icon must end with two \r 54 | Icon 55 | 56 | # Thumbnails 57 | ._* 58 | 59 | # Files that might appear in the root of a volume 60 | .DocumentRevisions-V100 61 | .fseventsd 62 | .Spotlight-V100 63 | .TemporaryItems 64 | .Trashes 65 | .VolumeIcon.icns 66 | .com.apple.timemachine.donotpresent 67 | 68 | # Directories potentially created on remote AFP share 69 | .AppleDB 70 | .AppleDesktop 71 | Network Trash Folder 72 | Temporary Items 73 | .apdisk 74 | 75 | ##### Test file. 76 | test.php 77 | 78 | ##### SQL file. 79 | *.sql 80 | *.sqlite 81 | 82 | ##### Data files 83 | *.csv 84 | 85 | ##### Archive files 86 | *.zip 87 | *.gz 88 | *.tar 89 | *.tgz 90 | *.7z 91 | 92 | ##### dotenv – Application environment constants 93 | *.env 94 | 95 | ##### Backup 96 | *.bak 97 | *.bakup 98 | *.gho 99 | *.old 100 | *.ori 101 | *.orig 102 | *.original 103 | *.tmp 104 | *.temp 105 | 106 | ##### Git Patches 107 | *.patch 108 | 109 | ##### GPG 110 | secring.* 111 | 112 | ##### Dropbox 113 | # Dropbox 114 | .dropbox 115 | .dropbox.attr 116 | .dropbox.cache 117 | 118 | ##### SynopsysVCS 119 | # Waveform formats 120 | *.vcd 121 | *.vpd 122 | *.evcd 123 | *.fsdb 124 | 125 | # Default name of the simulation executable. A different name can be 126 | # specified with this switch (the associated daidir database name is 127 | # also taken from here): -o / 128 | simv 129 | 130 | # Generated for Verilog and VHDL top configs 131 | simv.daidir/ 132 | simv.db.dir/ 133 | 134 | # Infrastructure necessary to co-simulate SystemC models with 135 | # Verilog/VHDL models. An alternate directory may be specified with this 136 | # switch: -Mdir= 137 | csrc/ 138 | 139 | # Log file - the following switch allows specifying the file that will be 140 | # used to write all messages from the simulation: -l 141 | *.log 142 | error_log 143 | error.log 144 | 145 | # Coverage results (generated with urg) and database location. The 146 | # following switch can also be used: urg -dir .vdb 147 | simv.vdb/ 148 | urgReport/ 149 | 150 | # DVE and UCLI related files. 151 | DVEfiles/ 152 | ucli.key 153 | 154 | # When the design is elaborated for DirectC, the following file is created 155 | # with declarations for C/C++ functions. 156 | vc_hdrs.h 157 | 158 | ##### SVN 159 | .svn/ 160 | 161 | ##### Mercurial 162 | .hg/ 163 | .hgignore 164 | .hgsigs 165 | .hgsub 166 | .hgsubstate 167 | .hgtags 168 | 169 | ##### Bazaar 170 | .bzr/ 171 | .bzrignore 172 | 173 | ##### CVS 174 | /CVS/* 175 | **/CVS/* 176 | .cvsignore 177 | */.cvsignore 178 | 179 | ##### TortoiseGit 180 | # Project-level settings 181 | /.tgitconfig 182 | 183 | ##### PuTTY 184 | # Private key 185 | *.ppk 186 | 187 | ##### VIM 188 | # Swap 189 | [._]*.s[a-v][a-z] 190 | !*.svg # comment out to include vector files in your project 191 | [._]*.sw[a-p] 192 | [._]s[a-rt-v][a-z] 193 | [._]ss[a-gi-z] 194 | [._]sw[a-p] 195 | 196 | # Session 197 | Session.vim 198 | Sessionx.vim 199 | 200 | Temporary 201 | .netrwhist 202 | *~ 203 | # Auto-generated tag files 204 | tags 205 | # Persistent undo 206 | [._]*.un~ 207 | 208 | ##### Emacs 209 | # -*- mode: gitignore; -*- 210 | *~ 211 | \#*\# 212 | /.emacs.desktop 213 | /.emacs.desktop.lock 214 | *.elc 215 | auto-save-list 216 | tramp 217 | .\#* 218 | 219 | # Org-mode 220 | .org-id-locations 221 | *_archive 222 | 223 | # flymake-mode 224 | *_flymake.* 225 | 226 | # eshell files 227 | /eshell/history 228 | /eshell/lastdir 229 | 230 | # elpa packages 231 | /elpa/ 232 | 233 | # reftex files 234 | *.rel 235 | 236 | # AUCTeX auto folder 237 | /auto/ 238 | 239 | # cask packages 240 | .cask/ 241 | dist/ 242 | 243 | # Flycheck 244 | flycheck_*.el 245 | 246 | # server auth directory 247 | /server/ 248 | 249 | # projectiles files 250 | .projectile 251 | 252 | # directory configuration 253 | .dir-locals.el 254 | 255 | # network security 256 | /network-security.data 257 | 258 | ##### SublimeText 259 | # Cache files for Sublime Text 260 | *.tmlanguage.cache 261 | *.tmPreferences.cache 262 | *.stTheme.cache 263 | # Workspace files are user-specific 264 | *.sublime-workspace 265 | 266 | # Project files should be checked into the repository unless a significant 267 | # proportion of contributors will probably not be using Sublime Text 268 | # *.sublime-project 269 | 270 | # SFTP configuration file 271 | sftp-config.json 272 | sftp-config-alt*.json 273 | 274 | # Package control specific files 275 | Package Control.last-run 276 | Package Control.ca-list 277 | Package Control.ca-bundle 278 | Package Control.system-ca-bundle 279 | Package Control.cache/ 280 | Package Control.ca-certs/ 281 | Package Control.merged-ca-bundle 282 | Package Control.user-ca-bundle 283 | oscrypto-ca-bundle.crt 284 | bh_unicode_properties.cache 285 | 286 | # Sublime-github package stores a GitHub token in this file 287 | # https://packagecontrol.io/packages/sublime-github 288 | GitHub.sublime-settings 289 | 290 | ##### TextMate 291 | *.tmproj 292 | *.tmproject 293 | tmtags 294 | 295 | ##### VisualStudioCode 296 | .vscode/ 297 | .vscode/* 298 | !.vscode/settings.json 299 | !.vscode/tasks.json 300 | !.vscode/launch.json 301 | !.vscode/extensions.json 302 | *.code-workspace 303 | 304 | # Local History for Visual Studio Code 305 | .history/ 306 | 307 | ##### NetBeans 308 | **/nbproject/private/ 309 | **/nbproject/Makefile-*.mk 310 | **/nbproject/Package-*.bash 311 | build/ 312 | nbbuild/ 313 | dist/ 314 | nbdist/ 315 | .nb-gradle/ 316 | 317 | ##### JetBrains 318 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 319 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 320 | 321 | # User-specific stuff 322 | .idea/**/workspace.xml 323 | .idea/**/tasks.xml 324 | .idea/**/usage.statistics.xml 325 | .idea/**/dictionaries 326 | .idea/**/shelf 327 | 328 | # Generated files 329 | .idea/**/contentModel.xml 330 | 331 | # Sensitive or high-churn files 332 | .idea/**/dataSources/ 333 | .idea/**/dataSources.ids 334 | .idea/**/dataSources.local.xml 335 | .idea/**/sqlDataSources.xml 336 | .idea/**/dynamic.xml 337 | .idea/**/uiDesigner.xml 338 | .idea/**/dbnavigator.xml 339 | 340 | ##### Eclipse 341 | .metadata 342 | bin/ 343 | tmp/ 344 | *~.nib 345 | local.properties 346 | .settings/ 347 | .loadpath 348 | .recommenders 349 | 350 | ##### Dreamweaver 351 | # DW Dreamweaver added files 352 | _notes 353 | _compareTemp 354 | configs/ 355 | dwsync.xml 356 | dw_php_codehinting.config 357 | *.mno 358 | 359 | # External tool builders 360 | .externalToolBuilders/ 361 | 362 | # Locally stored "Eclipse launch configurations" 363 | *.launch 364 | 365 | # PyDev specific (Python IDE for Eclipse) 366 | *.pydevproject 367 | 368 | # CDT-specific (C/C++ Development Tooling) 369 | .cproject 370 | 371 | # CDT- autotools 372 | .autotools 373 | 374 | # Java annotation processor (APT) 375 | .factorypath 376 | 377 | # PDT-specific (PHP Development Tools) 378 | .buildpath 379 | 380 | # sbteclipse plugin 381 | .target 382 | 383 | # Tern plugin 384 | .tern-project 385 | 386 | # TeXlipse plugin 387 | .texlipse 388 | 389 | # STS (Spring Tool Suite) 390 | .springBeans 391 | 392 | # Code Recommenders 393 | .recommenders/ 394 | 395 | # Annotation Processing 396 | .apt_generated/ 397 | .apt_generated_test/ 398 | 399 | # Scala IDE specific (Scala & Java development for Eclipse) 400 | .cache-main 401 | .scala_dependencies 402 | .worksheet 403 | 404 | # Uncomment this line if you wish to ignore the project description file. 405 | # Typically, this file would be tracked if it contains build/dependency configurations: 406 | #.project 407 | 408 | ##### Dreamweaver 409 | # DW Dreamweaver added files 410 | _notes 411 | _compareTemp 412 | configs/ 413 | dwsync.xml 414 | dw_php_codehinting.config 415 | *.mno 416 | 417 | ##### CodeKit 418 | # General CodeKit files to ignore 419 | config.codekit 420 | config.codekit3 421 | /min 422 | 423 | #### Gradle 424 | .gradle 425 | **/build/ 426 | !src/**/build/ 427 | 428 | # Ignore Gradle GUI config 429 | gradle-app.setting 430 | 431 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 432 | !gradle-wrapper.jar 433 | 434 | # Cache of project 435 | .gradletasknamecache 436 | 437 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 438 | # gradle/wrapper/gradle-wrapper.properties 439 | 440 | ##### Composer 441 | composer.phar 442 | /vendor/ 443 | 444 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control 445 | # You may choose to ignore a library lock file https://getcomposer.org/doc/02-libraries.md#lock-file 446 | composer.lock 447 | 448 | ##### PHP CodeSniffer 449 | # gitignore for the PHP Codesniffer framework 450 | # website: https://github.com/squizlabs/PHP_CodeSniffer 451 | # 452 | # Recommended template: PHP.gitignore 453 | 454 | /wpcs/* 455 | 456 | ##### SASS 457 | .sass-cache/ 458 | *.css.map 459 | *.sass.map 460 | *.scss.map 461 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## [3.1.7] - 2025-04-27 5 | ### Updates 6 | - Fixes Moodle 5.0 compatibility issue. 7 | - Compatible with Moodle up to v5.0. 8 | - Updated copyright for 2025. 9 | 10 | ## [3.1.6] - 2024-10-03 11 | ### Updates 12 | - No version change as there was no change to the code. 13 | - Tested compatible with Moodle 4.5. 14 | 15 | ## [3.1.6] - 2024-07-22 16 | ### Updated 17 | - Fixed deprecated strings in Moodle 4.4. 18 | 19 | ## [3.1.5] - 2024-06-28 20 | ### Update 21 | - Fixed some compatibility issues with PHP 5.6 and 7.0. 22 | - DNS test exclamation triangles icons now showing up in older versions of Moodle LMS. 23 | - Improved SPF, DMIK and DMARC detection. 24 | 25 | ## [3.1.2] - 2024-04-28 26 | ### Updated 27 | - Fixed incorrect error message for invalid DMARC ruf. 28 | - Cleaned-up language file. 29 | 30 | ## [3.1.1] - 2024-04-23 31 | ### Added 32 | - Github CI Workflows. 33 | - Github security reporting 34 | ### Updated 35 | - Bug reporting form. 36 | - Tested compatible with PHP 5.6 to 8.3. 37 | - Compatible with Moodle up to v4.4. 38 | 39 | ## [3.1.0] - 2024-02-22 40 | ### Added 41 | - Now tests domain for SPF configuration. 42 | - Now tests Moodle and domain for DKIM configuration. 43 | - Now tests domain for DMARC configuration. 44 | - Now tests domain for BIMI configuration. 45 | - Updated copyright for 2024. 46 | 47 | ## [3.0.1] - 2023-10-23 48 | ### Updated 49 | - Now only run the tests that make sense in order to reduce unlikely recommendations. 50 | - Now displays missing recommendations. 51 | - Tested compatible with PHP 5.6 to 8.2. 52 | 53 | ## [3.0.0] - 2023-10-20 54 | ### Added 55 | - New diagnostic feature provides issue-specific information and some common solutions. 56 | - New detection of SMTP credential issue. 57 | - New detection of SMTP server connection failure/timeout. 58 | - New detection of SMTP server rejection. 59 | - New detection of connection timeout issues. 60 | - New detection of DNS resolution failure. 61 | - New detection of missing port or SSL/TLS protocol/port mismatch. 62 | - New detection of closed port. 63 | - New in-app information to help you troubleshoot if you don't receive the test email. 64 | ### Updated 65 | - Documentation. Links to http:// have been replaced with https://. 66 | - Compatible with Moodle up to v4.3. 67 | 68 | ## [2.0.2] - 2022-05-06 69 | ### Updated 70 | - Fix-31: Corrected deprecated FILTER_SANITIZE_STRING deprecation notice in PHP 8.1. 71 | - Fix-30: Corrected undefined $CFG->branch error when installing at the same time as initial Moodle install. 72 | - Fix-20: Now correctly handles site names with special characters such as ampersands. 73 | - Compatible with PHP 5.6 to 8.1. 74 | - Compatible with Moodle up to v4.2. 75 | - Copyright notice for 2023. 76 | 77 | ## [2.0.1] - 2022-12-11 78 | ### Added 79 | - Added documentation for sending email via Gmail. 80 | ### Updated 81 | - Added missing string for Moodle 2.4 to 3.9. 82 | - Compatible with PHP 5.6 to 8.0. 83 | - Compatible with Moodle up to v4.1. 84 | 85 | ## [2.0.0] - 2022-04-24 86 | ### Added 87 | - Detects and reports the log location if mail.log is set in php.ini. 88 | - Detects if email diverting is enabled. 89 | - Detects if email/messaging is disabled by way of $CFG->noemailever. 90 | ### Updated 91 | - Removed db directory as there are no tables used by this plugin. 92 | - .gitignore 93 | - Compatible with PHP 5.6 to 7.4. 94 | - Compatible with Moodle up to v4.0. 95 | - Copyright notice for 2022. 96 | 97 | ## [1.4.0] - 2020-09-20 98 | ### Added 99 | - composer.lock 100 | ### Updated 101 | - Fixed display issue with Moodle 3.9. 102 | - Compatibility with PHP 5.6 to 7.3. 103 | - Copyright notice. 104 | - Fixed composer installation issues with mediamaisteri/moodle-installer. See https://github.com/juho-jaakkola/moodle-project 105 | - Compatible with Moodle up to v3.11. 106 | 107 | ## [1.3.0] - 2019-11-17 108 | ### Added 109 | - If PHP mail() function method is used instead of SMTP, it is not possible to capture the dialogue between Moodle and an SMPT server. Information will now be displayed showing potential locations for a server log. 110 | - Documentation suggesting adding a port number to the SMTP server address. 111 | ### Updated 112 | - Fixed compatibility with Moodle 3.8 due to $CFG->debugsmtp now being optional. 113 | - Copyright notice. 114 | 115 | ## [1.2.1] - 2018-05-21 116 | ### Added 117 | - Support for Privacy API. 118 | - More answers in FAQ section of README.md. 119 | - From and To addresses in status message. 120 | - Support for Reply-to address. 121 | ### Updated 122 | - Fixed a PHP notice that rarely but occasionally occurred when reloading the results page without going through the form again. 123 | - Documentation. 124 | - phpDocs error. 125 | 126 | ## [1.1.3] - 2018-04-30 127 | No code changes. 128 | ### Updated 129 | - Moodle eMailTest has been successfully tested for compatibility with Moodle 2.5 to 3.5. 130 | - More answers in FAQ section of README.md. 131 | - Documentation. 132 | - Copyright for 2018. 133 | 134 | ## [1.1.2] - 2017-10-29 135 | No code changes. 136 | ### Updated 137 | - Moodle eMailTest has been successfully tested for compatibility with Moodle 2.5 to 3.3. 138 | 139 | ## [1.1.1] - 2016-05-12 140 | No code changes. 141 | ### Added 142 | - CONTRIBUTE.md. 143 | ### Updated 144 | - Removed Limitations notice in the README.md file. This plugin is confirmed to work with PHP 7.1 (thanks davidpesce) 145 | - Moodle eMailTest has been successfully tested for compatibility with Moodle 2.5 to 3.3. 146 | - Reorganized README.md (New: logo, status badges, table of contents, contributing, etc). 147 | 148 | ## [1.1.0] - 2016-02-03 149 | ### Added 150 | - Option to always show SMTP connection log, even if there is no error. 151 | - Now detects whether Moodle should be always sending from no-reply address. 152 | - Now notifies you if an email address is invalid. 153 | - New option to send from primary admin user's email address. 154 | - Now displays Moodle informative debug messages from email_to_user(). 155 | - Added more answers to FAQ section of documentation relating to cron and Moodle 3.2+. 156 | 157 | ## [1.0.1] - 2016-01-02 158 | ### Updated 159 | - Made source code comments clearer and phpdoc valid. 160 | - Corrected and updated copyright notice to include 2017. 161 | - Corrected missing closing

tag in English language file. (Thanks lucaboesch!) 162 | 163 | ## [1.0.0] - 2016-11-27 164 | ### Added 165 | - A notification will now be displayed if cron hasn't run in the last 24 hours. 166 | - FAQ, in README.md, indicating what to do if you see the new cron notification. 167 | - Provides better recommendations depending on whether the SMTP server 168 | refused communications from Moodle or it refused delivery of the message. 169 | ### Changed 170 | - Changed the visible name of the plugin to eMail Test to help people find it. 171 | - Since there have been no issues reported, the plugin is now considered STABLE. 172 | - The link to eMail Test will now appear in the Email section of the Server tab 173 | in Moodle 3.2's new Site Adminstration page. 174 | - Moodle eMailTest has been successfully tested for compatibility with 175 | Moodle 2.5 to 3.2. 176 | 177 | ## [0.3.0] - 2016-05-21 178 | ### Added 179 | - This CHANGELOG.md file. 180 | - French Translation in AMOS - Update your French language packs! 181 | - Link to plugin's discussion forum in the plugin's Moodle.org Plugins directory. 182 | - README.md now contains answers to common questions. 183 | - Displays whether using PHP mail() function or talking directly to the SMTP server. 184 | - Option to choose whether test email will be sent from your email address, 185 | the noreply user email address, or the support email address. 186 | - Moodle MailTest is now compatible with Moodle 2.5 to 3.1 LTS. 187 | 188 | ## [0.2.0] - 2015-11-05 189 | ### Added 190 | - Moodle MailTest is Now also compatible with Moodle 2.8, 2.9 and 3.0. 191 | - Added link to plugin's discussion forum in the plugin's Moodle.org Plugins directory. 192 | ### Updated 193 | - Plugin's status changed from ALPHA to BETA. 194 | - Corrected links from the plugin's page in the Moodle.org Plugins directory. 195 | - Corrected documentation and added formatting to make it easier to read on GitHub. 196 | 197 | ## [0.1.0] - 2015-11-02 198 | ### Added 199 | - Initial public release on Moodle.org and GitHub. 200 | - Plugin officially compatible and tested with Moodle 2.5, 2.6 and 2.7. 201 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at [TNG Consulting Inc.] 63 | (https://www.tngconsulting.ca/contact). 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ------------------- 3 | 4 | 1. File an issue to notify the maintainers about what you are working on. 5 | 2. Fork the repo, develop and test your code changes, add docs. 6 | 3. Make sure that your commit messages clearly describe the changes. 7 | 4. Send a pull request. 8 | 9 | File an Issue 10 | ------------------- 11 | 12 | Use the issue tracker to start the discussion. It is possible that someone else is already working on your idea, your approach is not quite right, or that the functionality exists already. The ticket you file in the issue tracker will be used to hash that all out. 13 | 14 | Keep in mind that the maintainers get final say on whether new features will be integrated into the project. 15 | 16 | Style Guides 17 | ------------------- 18 | 1. Write in UTF-8 in PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2. 19 | 2. Follow the official[Moodle Coding Style Guide](https://moodledev.io/general/development/policies/codingstyle). 20 | 3. Fully test your code with Moodle **Debug Messages** setting set to **DEVELOPER: extra Moodle debug messages for developers** and **Display debug messages** setting checked. Ensure that there are no errors or warnings at all. 21 | 4. Ensure that your code passes all tests using the [Moodle Code Checker](https://moodle.org/plugins/local_codechecker) and [Moodle PHPdoc check](https://moodle.org/plugins/local_moodlecheck) plugins. Ensure that there are no errors or warnings at all. 22 | 5. Look at the existing style and adhere accordingly. 23 | 24 | Fork the Repository 25 | ------------------- 26 | 27 | Be sure to add the relevant tests before making the pull request. The documentation will be updated automatically when we merge to the **master** branch, but you should also build the documentation yourself and make sure it is readable. 28 | 29 | Make a Pull Request 30 | ------------------- 31 | 32 | Once you have made all your changes, tests, and updated the documentation, make a pull request to move everything back into the main branch of the **repository**. Be sure to reference the original issue in the pull request. Expect some back-and-forth with regards to style and compliance of these rules. 33 | 34 | Versioning 35 | ------------------- 36 | We use [SemVer](https://semver.org/) for versioning. 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Local eMailTest plugin for Moodle 4 | ================================= 5 | ![PHP](https://img.shields.io/badge/PHP-v5.6%20to%208.3-blue.svg) 6 | ![Moodle](https://img.shields.io/badge/Moodle-v2.5%20to%20v4.5-orange.svg) 7 | [![GitHub Issues](https://img.shields.io/github/issues/michael-milette/moodle-local_mailtest.svg)](https://github.com/michael-milette/moodle-local_mailtest/issues) 8 | [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg)](#contributing) 9 | [![License](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](#license) 10 | 11 | # Table of Contents 12 | 13 | - [Basic Overview](#basic-overview) 14 | - [Requirements](#requirements) 15 | - [Download eMail Test for Moodle](#download-email-test-for-moodle) 16 | - [Installation](#installation) 17 | - [Usage](#usage) 18 | - [Updating](#updating) 19 | - [Uninstallation](#uninstallation) 20 | - [Limitations](#limitations) 21 | - [Language Support](#language-support) 22 | - [Frequently Asked Questions (FAQ)](#faq) 23 | - [Contributing](#contributing) 24 | - [Motivation for this plugin](#motivation-for-this-plugin) 25 | - [Further information](#further-information) 26 | - [License](#license) 27 | 28 | # Basic Overview 29 | 30 | The eMailTest module for Moodle allows administrators to test Moodle's email system. A trace of the SMTP dialogue will be displayed if the email message cannot be sent for any reason. 31 | 32 | Once the test email has been sent, you will need to check your email in-box to confirm that the email message was successfully delivered. This plugin will not do that for you. 33 | 34 | [(Back to top)](#table-of-contents) 35 | 36 | # Requirements 37 | 38 | This plugin requires Moodle 2.5+, 3.x+, 4.x+ or 5.x+ from https://moodle.org 39 | 40 | [(Back to top)](#table-of-contents) 41 | 42 | # Download eMail Test for Moodle 43 | 44 | The most recent STABLE release of eMail Test for Moodle is available from: 45 | https://moodle.org/plugins/local_mailtest 46 | 47 | The most development release can be found at: 48 | https://github.com/michael-milette/moodle-local_mailtest 49 | 50 | [(Back to top)](#table-of-contents) 51 | 52 | # Installation 53 | 54 | Install the plugin, like any other plugin, to the following folder: 55 | 56 | /local/mailtest 57 | 58 | See https://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins. 59 | 60 | There are no special considerations required for updating the plugin. 61 | 62 | [(Back to top)](#table-of-contents) 63 | 64 | # Usage 65 | 66 | There are no configurable settings for this plugin at this time. 67 | 68 | The local_mailtest plugin is designed allow administrators to test Moodle to ensure the email message system is correctly configured. 69 | 70 | Once installed, login as a Moodle administrator and then click: 71 | 72 | Home > Site Administration > Server > eMail Test 73 | 74 | Enter the email address of the recipient where you want to send the message and click the [Send a test message] button. 75 | 76 | If the email message was successfully sent by Moodle, you will see a message that says "Success - The test message was successfully delivered to the SMTP server.". If it fails to send the email, a dialogue between the Moodle and the SMTP server will be displayed. 77 | 78 | [(Back to top)](#table-of-contents) 79 | 80 | # Updating 81 | 82 | There are no special considerations required for updating the plugin. 83 | 84 | The first public BETA version was released on 2015-11-01. This plugin is now considered STABLE. 85 | 86 | For more information on releases since then, see 87 | [CHANGELOG.md](https://github.com/michael-milette/moodle-local_mailtest/blob/master/CHANGELOG.md). 88 | 89 | [(Back to top)](#table-of-contents) 90 | 91 | # Uninstallation 92 | 93 | Uninstalling the plugin by going into the following: 94 | 95 | Home > Administration > Site Administration > Plugins > Manage plugins > eMail Test 96 | 97 | ...and click Uninstall. You may also need to manually delete the following folder: 98 | 99 | /local/mailtest 100 | 101 | [(Back to top)](#table-of-contents) 102 | 103 | # Limitations 104 | 105 | There are no known limitations at this time. 106 | 107 | [(Back to top)](#table-of-contents) 108 | 109 | # Language Support 110 | 111 | This plugin includes support for the English language. Additional languages including French are supported if you've installed one or more additional Moodle language packs. 112 | 113 | If you need a different language that is not yet supported, please feel free to contribute using the Moodle AMOS Translation Toolkit for Moodle at https://lang.moodle.org/ 114 | 115 | This plugin has not been tested for right-to-left (RTL) language support. If you want to use this plugin with a RTL language and it doesn't work as-is, feel free to prepare a pull request and submit it to the project page at: 116 | 117 | https://github.com/michael-milette/moodle-local_mailtest 118 | 119 | [(Back to top)](#table-of-contents) 120 | 121 | # FAQ 122 | 123 | ## Frequently Asked Questions 124 | 125 | ### Why do I get a 500 server error when I use eMailTest? 126 | 127 | This plugin has been extensively tested and used on hundreds of sites. If you are getting this error, it is likely that you have a file owner/group permissions issue on your server which needs to be resolved. 128 | 129 | ### Why does it say that Moodle sent the test message successfully yet I did not receive the email? 130 | 131 | This could be due to a number of reasons including but not limited to: 132 | 133 | * Incorrect PHP Mail settings in your php.ini file (if you have not configured Moodle's SMTP settings). 134 | * You may have an anti-virus or firewall blocking email communications. 135 | * The mail server receiving your email may be discarding emails received from your site. 136 | * The test email may be blocked by anti-spam filters. Check your junk mail folder. 137 | 138 | ### How do I find out the correct email settings I should be using? 139 | 140 | Contact your network administrator or your web hosting provider. These are typically the same settings as you would use for an email client but the administrator may need to add special settings to allow emails to be sent from your `support` and `no-reply` email addresses. 141 | 142 | ### Why is the test emails not being sent successfully? 143 | 144 | Your SMTP email settings are incorrect or the mail server is refusing emails coming from your Moodle site. Read the whole communications dialogue that is displayed when you send a test message. It will often provide some hint of where the problem might be. 145 | 146 | ### What is the difference between PHP Mail and Moodle SMTP Mail? 147 | 148 | If you don't configure the mail settings in Moodle, Moodle will hand off the delivery of email to PHP's built-in mail system. Its settings are typically in your server's PHP.INI file. If you do configure the SMTP settings in Moodle, it will attempt to deliver emails directly to the local SMTP server. 149 | 150 | ### How can I use this tool to send emails from other email addresses? 151 | 152 | You can't. This is to prevent the tool from being used to send spam. If you really must, you can temporarily test the email address of one of the following "From" addresses: 153 | 154 | * Your user account 155 | * Support 156 | * No-reply 157 | * Primary admin 158 | 159 | ### My email used to work in Moodle previous to 3.2. After upgrading to Moodle 3.2 or later, why can't my site send emails? 160 | 161 | As of Moodle 3.2, use of the no-reply email address is no longer optional in many cases. You will need to make sure it is now configured correctly. Some mail server may even only permit connections if this is actually a valid email address. 162 | 163 | ### Why do I see a message about cron not having run for at least 24 hours? 164 | 165 | IMPORTANT - See https://docs.moodle.org/en/Cron . If a link is included within the message, clicking it will cause Moodle to try sending queued messages immediately. However, future message will still not be sent automatically. Clicking the link instead of configuring cron will just hide the notice for 24 hours after which it will return until you fix this issue. 166 | 167 | If for some reason you are unable to setup an automated cron job and don't see the link, you can enable the link and allow remote running of the cron job by going to Site administration >Security > Site Policies and unchecking **Cron execution via command line only**. For a little extra security, also set a **Cron password for remote access**. 168 | 169 | ### Why do I see some debugging code in the communications log even though debugging is turned off? 170 | 171 | Moodle does some validation before sending an email and can display some useful information so we've enabled some minimal display of debugging information. Informative lines start with **email_to_user**. You can ignore the line number references that follow the information line. 172 | 173 | ### Regardless of which "from" email address I use, the test email always arrives from the same email address. Why? 174 | 175 | This is likely a setting in your mail server. To confirm which email address was used to send the email, look at the bottom of the status message after you try to send the email. If the test email was successfully delivered, you can also try to reply to the test message and take a look at the To email address. There is no need to actually send the reply. 176 | 177 | ### I am not sure if the problem is with Moodle, my mail server or my firewall. What should I do? 178 | 179 | First, the problem is very unlikely to be Moodle. Moodle is used by organization in virtually every country of the world. If there was a problem, someone would have spoken up by now. That said, it could be your email settings. To find out if it is potentially your Moodle settings or firewall, or if it is you mail server, try setting Moodle up to use Gmail as your email server. If it works, it is very likely your email settings. If it doesn't, you might have a firewall blocking email traffic or your email server is incorrectly configured. 180 | 181 | ### How can I use Gmail to send SMTP emails from Moodle? 182 | 183 | Gmail requires that you create an [App Password](https://support.google.com/mail/answer/185833?hl=en) to send email for Moodle. 184 | 185 | For more details as well as some of the limitations, see the Moodle documentation on [Email Setup Gmail](https://docs.moodle.org/en/Email_setup_gmail).- 186 | 187 | ### All the settings seem to be correct. What else can I try? 188 | 189 | Despite your best efforts, sometimes you will find that a :port Number needs to be added after the address of the SMTP server. Example: smtp.example.com:587 190 | 191 | ### Are there any security considerations? 192 | 193 | Use of this plugin is restricted to Moodle Site Administrators and allows them to submit an email through a restricted web form that only they can access. 194 | 195 | ## Other questions 196 | 197 | Got a burning question that is not covered here? If you still can't find your answer, submit your question in the Moodle forums or open a new issue on Github at: 198 | 199 | https://github.com/michael-milette/moodle-local_mailtest/issues 200 | 201 | [(Back to top)](#table-of-contents) 202 | 203 | # Contributing 204 | 205 | If you are interested in helping, please take a look at our [contributing](https://github.com/michael-milette/moodle-local_mailtest/blob/master/CONTRIBUTING.md) guidelines for details on our code of conduct and the process for submitting pull requests to us. 206 | 207 | ## Contributors 208 | 209 | Michael Milette - Author and Lead Developer 210 | 211 | Big thank you to the following contributors. (Please let me know if I forgot to include you in the list): 212 | 213 | * laurentdavid: Fixed deprecated strings in Moodle 4.4 (2024). 214 | 215 | ## Pending Features 216 | 217 | Let us know if you have any suggestions. 218 | 219 | [(Back to top)](#table-of-contents) 220 | 221 | # Motivation for this plugin 222 | 223 | The development of this plugin was motivated through our own experience in Moodle development and comments in the Moodle support forums and is supported by TNG Consulting Inc. 224 | 225 | [(Back to top)](#table-of-contents) 226 | 227 | # Further information 228 | 229 | For further information regarding the local_mailtest plugin, support or to report a bug, please visit the project page at: 230 | 231 | https://github.com/michael-milette/moodle-local_mailtest 232 | 233 | [(Back to top)](#table-of-contents) 234 | 235 | # License 236 | 237 | Copyright © 2015-2025 TNG Consulting Inc. - https://www.tngconsulting.ca/ 238 | 239 | This file is part of MailTest/eMailTest for Moodle - https://moodle.org/ 240 | 241 | eMailTest is free software: you can redistribute it and/or modify 242 | it under the terms of the GNU General Public License as published by 243 | the Free Software Foundation, either version 3 of the License, or 244 | (at your option) any later version. 245 | 246 | eMailTest is distributed in the hope that it will be useful, 247 | but WITHOUT ANY WARRANTY; without even the implied warranty of 248 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 249 | GNU General Public License for more details. 250 | 251 | You should have received a copy of the GNU General Public License 252 | along with eMailTest. If not, see . 253 | 254 | [(Back to top)](#table-of-contents) 255 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report (suspected) security vulnerabilities to https://tngconsulting.ca/contact. 6 | -------------------------------------------------------------------------------- /classes/mailtest_form.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Main form for eMailTest. 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngcosulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die; 27 | require_once($CFG->libdir . '/formslib.php'); 28 | 29 | /** 30 | * Form to prompt administrator for the recipient's email address. 31 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngcosulting.ca 32 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 | */ 34 | class mailtest_form extends moodleform { 35 | /** 36 | * Define the form. 37 | */ 38 | public function definition() { 39 | global $USER, $CFG; 40 | $mform = $this->_form; 41 | 42 | // Header. 43 | 44 | $mform->addElement('html', '

' . get_string('pluginname_help', 'local_mailtest') . '

'); 45 | 46 | // Send method. 47 | 48 | if (empty($CFG->smtphosts)) { 49 | $sendmethod = get_string('phpmethod', 'local_mailtest'); 50 | } else { 51 | $sendmethod = get_string('smtpmethod', 'local_mailtest', $CFG->smtphosts); 52 | } 53 | if ($CFG->branch >= 32) { 54 | $sendmethod .= ' (' . 55 | get_string('change', 'admin') . ')'; 56 | } else { 57 | $sendmethod .= ' (' . 58 | get_string('change', 'admin') . ')'; 59 | } 60 | $mform->addElement('static', 'sendmethod', get_string('sendmethod', 'local_mailtest'), $sendmethod); 61 | 62 | // Sender. 63 | 64 | $senderarray = []; 65 | $a = new stdClass(); 66 | $a->label = get_string('change', 'admin'); 67 | 68 | // Current user's email address. 69 | $a->email = $USER->email; 70 | if ($CFG->branch >= 32) { 71 | $a->url = '../../user/editadvanced.php?course=1#id_email'; 72 | } else { 73 | $a->url = '../../user/editadvanced.php?course=1#fitem_id_email'; 74 | } 75 | $a->type = get_string('youremail', 'local_mailtest'); 76 | $senderarray[] = $mform->createElement('radio', 'sender', '', get_string('from', 'local_mailtest', $a) 77 | . local_mailtest_checkdns(explode('@', $a->email)[1]), $a->email); 78 | if (!validate_email($a->email)) { 79 | $senderarray[] = $mform->CreateElement( 80 | 'static', 81 | 'error', 82 | '', 83 | html_writer::span(get_string('invalidemail'), 'statuswarning') 84 | ); 85 | } 86 | 87 | // Support email address. 88 | $primaryadmin = get_admin(); 89 | $a->email = empty($CFG->supportemail) ? $primaryadmin->email : $CFG->supportemail; 90 | $a->url = '../../admin/settings.php?section=supportcontact'; 91 | $a->type = get_string('supportemail', 'admin'); 92 | $senderarray[] = $mform->createElement('radio', 'sender', '', get_string('from', 'local_mailtest', $a) 93 | . local_mailtest_checkdns(explode('@', $a->email)[1]), $a->email); 94 | if (!validate_email($a->email)) { 95 | $senderarray[] = $mform->CreateElement( 96 | 'static', 97 | 'error', 98 | '', 99 | html_writer::span(get_string('invalidemail'), 'statuswarning') 100 | ); 101 | } 102 | 103 | // No Reply address. 104 | $a->email = empty($CFG->noreplyaddress) ? 'noreply@' . get_host_from_url($CFG->wwwroot) : $CFG->noreplyaddress; 105 | if ($CFG->branch >= 32) { 106 | $a->url = '../../admin/settings.php?section=outgoingmailconfig#admin-noreplyaddress'; 107 | $a->type = get_string('noreplyaddress', 'admin'); 108 | } else { 109 | $a->url = '../../admin/settings.php?section=messagesettingemail#noreplyaddress'; 110 | $a->type = get_string('noreplyaddress', 'message_email'); 111 | } 112 | $senderarray[] = $mform->createElement('radio', 'sender', '', get_string('from', 'local_mailtest', $a) 113 | . local_mailtest_checkdns(explode('@', $a->email)[1]), $a->email); 114 | if (!validate_email($a->email)) { 115 | $senderarray[] = $mform->CreateElement( 116 | 'static', 117 | 'error', 118 | '', 119 | html_writer::span(get_string('invalidemail'), 'statuswarning') 120 | ); 121 | } 122 | 123 | // Primary admin email address. 124 | $primaryadmin = get_admin(); 125 | $a->email = $primaryadmin->email; 126 | $a->url = '../../user/editadvanced.php?id=' . $primaryadmin->id; 127 | $a->type = get_string('primaryadminemail', 'local_mailtest'); 128 | $senderarray[] = $mform->createElement('radio', 'sender', '', get_string('from', 'local_mailtest', $a) 129 | . local_mailtest_checkdns(explode('@', $a->email)[1]), $a->email); 130 | if (!validate_email($a->email)) { 131 | $senderarray[] = $mform->CreateElement( 132 | 'static', 133 | 'error', 134 | '', 135 | html_writer::span(get_string('invalidemail'), 'statuswarning') 136 | ); 137 | } 138 | 139 | // Add group of sender radio buttons to form. 140 | $mform->setDefault('sender', $this->_customdata['fromdefault']); 141 | $mform->addGroup($senderarray, 'senderar', get_string('fromemail', 'local_mailtest'), ['
'], false); 142 | $mform->setType('sender', PARAM_EMAIL); 143 | $mform->addRule('senderar', get_string('required'), 'required'); 144 | 145 | // Recipient. 146 | 147 | $mform->addElement('text', 'recipient', get_string('toemail', 'local_mailtest'), 'maxlength="100" size="25" '); 148 | $mform->setType('recipient', PARAM_EMAIL); 149 | $mform->addRule('recipient', get_string('required'), 'required'); 150 | 151 | // Divert all emails. 152 | 153 | if (empty($CFG->divertallemailsto)) { 154 | $divertstatus = get_string('functiondisabled'); 155 | } else { 156 | $divertstatus = get_string('divertedto', 'local_mailtest', $CFG->divertallemailsto); 157 | } 158 | if ($CFG->branch >= 310) { 159 | // Only configurable in UI as of Moodle 3.10. 160 | $divertstatus .= ' (' . 161 | get_string('change', 'admin') . ')'; 162 | } 163 | if (!empty($CFG->divertallemailsto)) { 164 | $divertstatus .= local_mailtest_checkdns(explode('@', $CFG->divertallemailsto)[1]); 165 | } 166 | $mform->addElement('static', 'divertemails', get_string('divertallemails', 'local_mailtest'), $divertstatus); 167 | 168 | // Always show communications log - even on success. 169 | 170 | $mform->addElement('checkbox', 'alwaysshowlog', '', get_string('alwaysshowlog', 'local_mailtest')); 171 | $mform->setDefault('alwaysshowlog', ($CFG->debugdisplay && isset($CFG->debugsmtp) && $CFG->debugsmtp)); 172 | 173 | // Buttons. 174 | 175 | if ($disabled = !empty($CFG->noemailever)) { 176 | $mform->addElement( 177 | 'static', 178 | 'noemailever', 179 | html_writer::div(get_string('messagingdisable', 'error'), 'alert alert-danger'), 180 | html_writer::div(get_string('noemaileverset', 'message_airnotifier'), 'alert alert-danger') 181 | ); 182 | } 183 | $buttonarray = []; 184 | if (!$disabled) { 185 | $buttonarray[] = $mform->createElement('submit', 'send', get_string('sendtest', 'local_mailtest')); 186 | } 187 | $buttonarray[] = $mform->createElement('cancel'); 188 | 189 | $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); 190 | $mform->closeHeaderBefore('buttonar'); 191 | } 192 | 193 | /** 194 | * Validate submitted form data, recipient in this case, and returns list of errors if it fails. 195 | * 196 | * @param array $data The data fields submitted from the form. 197 | * @param array $files Files submitted from the form (not used) 198 | * 199 | * @return array List of errors to be displayed on the form if validation fails. 200 | */ 201 | public function validation($data, $files) { 202 | $errors = parent::validation($data, $files); 203 | 204 | if (empty($data['recipient'])) { 205 | $errors['recipient'] = get_string('err_email', 'form'); 206 | } 207 | 208 | return $errors; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /classes/privacy/provider.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Privacy Subsystem implementation for local_mailtest. 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngcosulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | namespace local_mailtest\privacy; 27 | 28 | /** 29 | * Privacy Subsystem for local_mailtest implementing null_provider. 30 | * 31 | * @copyright 2018 TNG Consulting Inc. 32 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 | */ 34 | class provider implements \core_privacy\local\metadata\null_provider { 35 | 36 | /** 37 | * Get the language string identifier with the component's language 38 | * file to explain why this plugin stores no data. 39 | * 40 | * @return string 41 | */ 42 | public static function get_reason(): string { 43 | return 'privacy:metadata'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "michael-milette/moodle-local_mailtest", 3 | "type": "moodle-local", 4 | "description": "eMailTest is a Moodle local plugin that can help diagnose SMTP email connectivity issues.", 5 | "license": "GPL-3.0+", 6 | "authors": [ 7 | { 8 | "name": "Michael Milette - TNG Consulting Inc.", 9 | "homepage": "https://www.tngconsulting.ca", 10 | "role": "Developer" 11 | } 12 | ], 13 | "require": { 14 | "composer/installers": "~1.0" 15 | }, 16 | "extra": { 17 | "installer-name": "mailtest" 18 | }, 19 | "support": { 20 | "issues": "https://github.com/michael-milette/moodle-local_mailtest/issues", 21 | "source": "https://github.com/michael-milette/moodle-local_mailtest/", 22 | "wiki": "https://github.com/michael-milette/moodle-local_mailtest/wiki", 23 | "docs": "https://github.com/michael-milette/moodle-local_mailtest/blob/master/README.md" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "e0189f80eb0b151be71bf49be2b97a15", 8 | "packages": [ 9 | { 10 | "name": "composer/installers", 11 | "version": "v1.9.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/composer/installers.git", 15 | "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/composer/installers/zipball/b93bcf0fa1fccb0b7d176b0967d969691cd74cca", 20 | "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0 || ^2.0" 25 | }, 26 | "replace": { 27 | "roundcube/plugin-installer": "*", 28 | "shama/baton": "*" 29 | }, 30 | "require-dev": { 31 | "composer/composer": "1.6.* || 2.0.*@dev", 32 | "composer/semver": "1.0.* || 2.0.*@dev", 33 | "phpunit/phpunit": "^4.8.36", 34 | "sebastian/comparator": "^1.2.4", 35 | "symfony/process": "^2.3" 36 | }, 37 | "type": "composer-plugin", 38 | "extra": { 39 | "class": "Composer\\Installers\\Plugin", 40 | "branch-alias": { 41 | "dev-master": "1.0-dev" 42 | } 43 | }, 44 | "autoload": { 45 | "psr-4": { 46 | "Composer\\Installers\\": "src/Composer/Installers" 47 | } 48 | }, 49 | "notification-url": "https://packagist.org/downloads/", 50 | "license": [ 51 | "MIT" 52 | ], 53 | "authors": [ 54 | { 55 | "name": "Kyle Robinson Young", 56 | "email": "kyle@dontkry.com", 57 | "homepage": "https://github.com/shama" 58 | } 59 | ], 60 | "description": "A multi-framework Composer library installer", 61 | "homepage": "https://composer.github.io/installers/", 62 | "keywords": [ 63 | "Craft", 64 | "Dolibarr", 65 | "Eliasis", 66 | "Hurad", 67 | "ImageCMS", 68 | "Kanboard", 69 | "Lan Management System", 70 | "MODX Evo", 71 | "MantisBT", 72 | "Mautic", 73 | "Maya", 74 | "OXID", 75 | "Plentymarkets", 76 | "Porto", 77 | "RadPHP", 78 | "SMF", 79 | "Thelia", 80 | "Whmcs", 81 | "WolfCMS", 82 | "agl", 83 | "aimeos", 84 | "annotatecms", 85 | "attogram", 86 | "bitrix", 87 | "cakephp", 88 | "chef", 89 | "cockpit", 90 | "codeigniter", 91 | "concrete5", 92 | "croogo", 93 | "dokuwiki", 94 | "drupal", 95 | "eZ Platform", 96 | "elgg", 97 | "expressionengine", 98 | "fuelphp", 99 | "grav", 100 | "installer", 101 | "itop", 102 | "joomla", 103 | "known", 104 | "kohana", 105 | "laravel", 106 | "lavalite", 107 | "lithium", 108 | "magento", 109 | "majima", 110 | "mako", 111 | "mediawiki", 112 | "modulework", 113 | "modx", 114 | "moodle", 115 | "osclass", 116 | "phpbb", 117 | "piwik", 118 | "ppi", 119 | "puppet", 120 | "pxcms", 121 | "reindex", 122 | "roundcube", 123 | "shopware", 124 | "silverstripe", 125 | "sydes", 126 | "sylius", 127 | "symfony", 128 | "typo3", 129 | "wordpress", 130 | "yawik", 131 | "zend", 132 | "zikula" 133 | ], 134 | "funding": [ 135 | { 136 | "url": "https://packagist.com", 137 | "type": "custom" 138 | }, 139 | { 140 | "url": "https://tidelift.com/funding/github/packagist/composer/composer", 141 | "type": "tidelift" 142 | } 143 | ], 144 | "time": "2020-04-07T06:57:05+00:00" 145 | } 146 | ], 147 | "packages-dev": [], 148 | "aliases": [], 149 | "minimum-stability": "stable", 150 | "stability-flags": [], 151 | "prefer-stable": false, 152 | "prefer-lowest": false, 153 | "platform": [], 154 | "platform-dev": [], 155 | "plugin-api-version": "1.1.0" 156 | } 157 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Displays the form and processes the form submission. 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngconsulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | // Include config.php. 27 | require_once(__DIR__ . '/../../config.php'); 28 | require_once($CFG->libdir . '/adminlib.php'); 29 | 30 | // Include our function library. 31 | $pluginname = 'mailtest'; 32 | require_once($CFG->dirroot . '/local/' . $pluginname . '/locallib.php'); 33 | 34 | // Globals. 35 | global $CFG, $OUTPUT, $USER, $SITE, $PAGE; 36 | 37 | // Ensure only administrators have access. 38 | $homeurl = new moodle_url('/'); 39 | require_login(); 40 | if (!is_siteadmin()) { 41 | redirect($homeurl, "This feature is only available for site administrators.", 5); 42 | } 43 | 44 | // URL Parameters. 45 | // There are none. 46 | 47 | // Include form. 48 | require_once(dirname(__FILE__) . '/classes/' . $pluginname . '_form.php'); 49 | 50 | // Heading ==========================================================. 51 | 52 | $title = get_string('pluginname', 'local_' . $pluginname); 53 | $heading = get_string('heading', 'local_' . $pluginname); 54 | $url = new moodle_url('/local/' . $pluginname . '/'); 55 | if ($CFG->branch >= 25) { // Moodle 2.5+. 56 | $context = context_system::instance(); 57 | } else { 58 | $context = get_system_context(); 59 | } 60 | 61 | $PAGE->set_pagelayout('admin'); 62 | $PAGE->set_url($url); 63 | $PAGE->set_context($context); 64 | $PAGE->set_title($title); 65 | $PAGE->set_heading($heading); 66 | admin_externalpage_setup('local_' . $pluginname); // Sets the navbar & expands navmenu. 67 | 68 | // Setup the form. 69 | 70 | $CFG->noreplyaddress = empty($CFG->noreplyaddress) ? 'noreply@' . get_host_from_url($CFG->wwwroot) : $CFG->noreplyaddress; 71 | 72 | if (!empty($CFG->emailonlyfromnoreplyaddress) || $CFG->branch >= 32) { // Always send from no reply address. 73 | // Use primary administrator's name if support name has not been configured. 74 | $primaryadmin = get_admin(); 75 | $CFG->supportname = empty($CFG->supportname) ? fullname($primaryadmin, true) : $CFG->supportname; 76 | // Use noreply address. 77 | $fromemail = local_mailtest_generate_email_user($CFG->noreplyaddress, format_string($CFG->supportname)); 78 | $fromdefault = $CFG->noreplyaddress; 79 | } else { // Otherwise defaults to send from primary admin user. 80 | $fromemail = get_admin(); 81 | $fromdefault = $fromemail->email; 82 | } 83 | 84 | $form = new mailtest_form(null, ['fromdefault' => $fromdefault]); 85 | if ($form->is_cancelled()) { 86 | redirect($homeurl); 87 | } 88 | 89 | echo $OUTPUT->header(); 90 | 91 | // Display or process the form. =====================================. 92 | 93 | $data = $form->get_data(); 94 | if (!$data) { // Display the form. 95 | echo $OUTPUT->heading($heading); 96 | 97 | // Display a warning if Cron hasn't run in a while. =============. 98 | 99 | $cronwarning = ''; 100 | if ($CFG->branch >= 37) { 101 | defined('MINSECS') || define('MINSECS', 200); // For pre-Moodle 3.9 compatibility. 102 | $lastcron = get_config('tool_task', 'lastcronstart'); 103 | $cronoverdue = ($lastcron < time() - 3600 * 24); 104 | $check = $PAGE->get_renderer('core', 'admin'); 105 | if ($cronoverdue) { 106 | $cronwarning .= $check->cron_overdue_warning($cronoverdue); 107 | } 108 | 109 | $lastcroninterval = get_config('tool_task', 'lastcroninterval'); 110 | $expectedfrequency = isset($CFG->expectedcronfrequency) ? $CFG->expectedcronfrequency : MINSECS; 111 | $croninfrequent = !$cronoverdue && ($lastcroninterval > ($expectedfrequency + MINSECS) 112 | || $lastcron < time() - $expectedfrequency); 113 | if ($croninfrequent) { 114 | $cronwarning .= $check->cron_infrequent_warning($croninfrequent); 115 | } 116 | } else { // Up to and including Moodle 3.6. 117 | if ($CFG->branch >= 27) { // Moodle 2.7+. 118 | $sql = 'SELECT MAX(lastruntime) FROM {task_scheduled}'; 119 | } else { 120 | $sql = 'SELECT MAX(lastcron) FROM {modules}'; 121 | } 122 | $lastcron = $DB->get_field_sql($sql); 123 | $cronoverdue = ($lastcron < time() - 3600 * 24); 124 | if ($cronoverdue) { // Cron is overdue. 125 | if (empty($CFG->cronclionly)) { 126 | // Determine build link to run cron. 127 | $cronurl = new moodle_url('/admin/cron.php'); 128 | if (!empty($CFG->cronremotepassword)) { 129 | $cronurl = new moodle_url('/admin/cron.php', ['password' => $CFG->cronremotepassword]); 130 | } 131 | $cronwarning .= get_string('cronwarning', 'admin', $cronurl->out()); 132 | } else { 133 | $cronwarning .= get_string('cronwarningcli', 'admin'); 134 | } 135 | } 136 | } 137 | 138 | if ($cronoverdue) { // Cron is overdue. 139 | $msg = ''; 140 | $msg .= '

' . get_string('warning') . '

'; 141 | $msg .= $cronwarning; 142 | $msg .= '

' . get_string('cron_help', 'admin'); 143 | if (!empty($CFG->branch)) { 144 | $icon = $OUTPUT->pix_icon('help', get_string('moreinfo')); 145 | $link = $CFG->docroot . '/' . $CFG->branch . '/' . substr(current_language(), 0, 2) . '/Cron'; 146 | $msg .= html_writer::link($link, $icon, ['class' => 'helplink', 'target' => '_blank', 'rel' => 'external']); 147 | } 148 | $msg .= '

'; 149 | $msg .= ''; 151 | local_mailtest_msgbox($msg, null, 3, 'alert alert-danger alert-block alert-dismissible fade show'); 152 | } 153 | 154 | // Display the form. ============================================. 155 | 156 | $form->display(); 157 | } else { 158 | // Send test email. 159 | if (!isset($data->sender)) { 160 | $data->sender = $CFG->noreplyaddress; 161 | } 162 | $fromemail = local_mailtest_generate_email_user($data->sender); 163 | 164 | if ($CFG->branch >= 26) { 165 | $toemail = core_text::strtolower($data->recipient); 166 | } else { 167 | $toemail = textlib::strtolower($data->recipient); 168 | } 169 | if ($toemail !== clean_param($toemail, PARAM_EMAIL)) { 170 | local_mailtest_msgbox(get_string('invalidemail'), get_string('error'), 2, 'errorbox', $url->out()); 171 | } 172 | $toemail = local_mailtest_generate_email_user($toemail, ''); 173 | if (email_should_be_diverted($toemail->email)) { 174 | $toemail->email = $toemail->email . ' (' . 175 | get_string('divertedto', 'local_' . $pluginname, $CFG->divertallemailsto) . ')'; 176 | } 177 | 178 | $subject = format_string($SITE->fullname, true, ['escape' => false]); 179 | 180 | // Add some system information. 181 | $a = new stdClass(); 182 | if (isloggedin()) { 183 | $a->regstatus = get_string('registered', 'local_' . $pluginname, $USER->username); 184 | } else { 185 | $a->regstatus = get_string('notregistered', 'local_' . $pluginname); 186 | } 187 | $a->lang = current_language(); 188 | $a->browser = $_SERVER['HTTP_USER_AGENT']; 189 | $a->referer = $_SERVER['HTTP_REFERER']; 190 | $a->release = $CFG->release; 191 | $a->ip = local_mailtest_getuserip(); 192 | $messagehtml = get_string('message', 'local_' . $pluginname, $a); 193 | $messagetext = html_to_text($messagehtml); 194 | 195 | if ($CFG->branch >= 404) { 196 | $fromsender = get_string('fromsender'); 197 | $torecipient = get_string('torecipient'); 198 | } else { 199 | $fromsender = get_string('from'); 200 | $torecipient = get_string('to'); 201 | } 202 | 203 | ob_end_flush(); 204 | ob_implicit_flush(true); 205 | echo '

' . get_string('testing', 'local_' . $pluginname) . '

'; 206 | echo '

' . $fromsender . ' : ' . $fromemail->email . '
207 | 🡇             🡇             🡇
208 | ' . get_string('server', 'local_' . $pluginname, (empty($CFG->smtphosts) ? 'PHPMailer' : $CFG->smtphosts)) . '
209 | 🡇             🡇             🡇
210 | ' . $torecipient . ' : ' . $toemail->email . '

'; 211 | ob_implicit_flush(false); 212 | 213 | // Manage Moodle SMTP debugging display. 214 | $debuglevel = $CFG->debug; 215 | $debugdisplay = $CFG->debugdisplay; 216 | $debugsmtp = isset($CFG->debugsmtp) && $CFG->debugsmtp; 217 | $showlog = !empty($data->alwaysshowlog) || ($debugdisplay && $debugsmtp); 218 | // Set debug level to a minimum of NORMAL: Show errors, warnings and notices. 219 | if ($CFG->debug < 15) { 220 | $CFG->debug = 15; 221 | } 222 | $CFG->debugdisplay = true; 223 | $CFG->debugsmtp = true; 224 | if (empty($CFG->smtphosts)) { 225 | $success = email_to_user($toemail, $fromemail, $subject, $messagetext, $messagehtml, '', '', true, $fromemail->email); 226 | $smtplog = get_string('nologavailable', 'local_' . $pluginname); 227 | if (!empty($phplog = ini_get('mail.log'))) { 228 | if ($phplog == 'syslog' && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { 229 | $smtplog .= '
mail.log : ' . get_string('winsyslog', 'local_' . $pluginname) . '
'; 230 | } else { 231 | $smtplog .= '
mail.log : ' . $phplog . '
'; 232 | } 233 | } 234 | } else { 235 | ob_start(); 236 | $success = email_to_user($toemail, $fromemail, $subject, $messagetext, $messagehtml, '', '', true, $fromemail->email); 237 | $smtplog = ob_get_contents(); 238 | ob_end_clean(); 239 | $smtplog = '
' . $smtplog . '
'; 240 | } 241 | 242 | $CFG->debug = $debuglevel; 243 | $CFG->debugdisplay = $debugdisplay; 244 | $CFG->debugsmtp = $debugsmtp; 245 | 246 | if ($success) { // Success. 247 | $title = get_string('success'); 248 | $msg = '

'; 249 | if (empty($CFG->smtphosts)) { 250 | $msg .= get_string('sentmailphp', 'local_' . $pluginname); 251 | } else { 252 | $msg .= get_string('sentmail', 'local_' . $pluginname); 253 | } 254 | 255 | // Display a list of common reasons the email may not have been delivered. 256 | if (empty($CFG->smtphosts)) { 257 | $extrainfo = '

  • ' . get_string('failphpmailerconfig', 'local_' . $pluginname) . '
  • '; 258 | } else { 259 | $extrainfo = ''; 260 | } 261 | $msg .= ' ' . get_string('commondeliveryissues', 'local_' . $pluginname, $extrainfo); 262 | 263 | local_mailtest_msgbox($msg, $title, 2, 'infobox', $url->out()); 264 | if ($showlog) { 265 | // Display debugging info if settings were already on before the test or user wants to force display. 266 | echo $smtplog; 267 | } 268 | } else if (!empty($CFG->smtphosts)) { 269 | // Failed to deliver message using SMTP. 270 | $errtype = 'errorunknown'; 271 | 272 | // Diagnose failed SMTP connection issues. 273 | 274 | $issues = ''; 275 | if (strpos($smtplog, '220') === false) { // Missing 220 code, connection failed. 276 | $errtype = 'errorcommunications'; 277 | 278 | // Check for domain, security protocol and port issues for each specified mail server. 279 | $hosts = explode(';', $CFG->smtphosts); 280 | foreach ($hosts as $host) { 281 | if (empty($host)) { 282 | continue; // Skip if blank. 283 | } 284 | 285 | // Split the host and the port. 286 | $host = explode(':', $host . ':25'); // Set default port to 25 in case none was specified. 287 | $host = $host[0]; 288 | $port = $host[1]; 289 | $port = (int)$port; 290 | 291 | // Check for DNS record lookup failure. Skip if host is an IP address. 292 | if ( 293 | filter_var($host, FILTER_VALIDATE_IP) === false // Not an IP address. 294 | && empty(@dns_get_record($host)) // The address does not have a DNS record. 295 | && gethostbyname($host) == $host 296 | ) { // Address does not resolve to an IP address (e.g. localhost). 297 | $issues .= '
  • ' . get_string('faildnslookup', 'local_' . $pluginname, $host) . '
  • '; 298 | break; 299 | } 300 | 301 | // If using SSL or TLS, port is not usually 25. 302 | if ($port == 25 && !empty($CFG->smtpsecure)) { 303 | // No port or port 25 was specified for a SSL/TLS connection. 304 | $issues .= '
  • ' . get_string('failmissingport', 'local_' . $pluginname, $CFG->smtpsecure) . '
  • '; 305 | } 306 | 307 | // Port is not 25 but a secure protocol was not specified. 308 | if ($port != 25 && empty($CFG->smtpsecure)) { 309 | // Non default port specified for a non SSL/TLS connection. 310 | $issues .= '
  • '; 311 | $issues .= get_string('failmissingprotocol', 'local_' . $pluginname, $port); 312 | $issues .= '
  • '; 313 | } 314 | 315 | // The port and protocol don't match. Although it can, the SSL port is rarely 587, and TLS is rarely 465. 316 | if ($port == 587 && $CFG->smtpsecure == 'ssl' || $port == 465 && $CFG->smtpsecure == 'tls') { 317 | $issues .= '
  • ' . get_string( 318 | 'failprotocolmismatch', 319 | 'local_' . $pluginname, 320 | ['port' => $port, 'protocol' => $CFG->smtpsecure] 321 | ) . '
  • '; 322 | } 323 | 324 | // Connection timeout issues. 325 | $fp = @fsockopen($host, $port, $errno, $errstr, 10); 326 | if (!$fp) { 327 | if (stripos($errstr, 'Connection timed out') !== false) { 328 | // Connection timed out due to possible issues such as ISP blocking outbound SMTP connections. 329 | $issues .= '
  • ' . get_string('failoutboundsmtpblocked', 'local_' . $pluginname) . '
  • '; 330 | } else { 331 | // Server's port was closed. 332 | $issues .= '
  • ' . get_string('failclosedport', 'local_' . $pluginname, $port) . '
  • '; 333 | } 334 | // Add a list common issues. 335 | $issues .= get_string('commoncommissues', 'local_' . $pluginname); 336 | break; 337 | } else { 338 | fclose($fp); 339 | } 340 | } 341 | } else if (strpos($smtplog, '250') === false) { // No 250 code. 342 | // No or very limited communication between Moodle and the SMTP server. 343 | $errtype = 'errorcommunications'; 344 | $issues .= get_string('failaccessdenied', 'local_' . $pluginname); 345 | } else { 346 | // SMTP mail server refused the email. 347 | $errtype = 'errorsend'; 348 | 349 | // Diagnose possible authentication issues. 350 | 351 | // Invalid credentials - username and/or password are incorrect. 352 | if (strpos($smtplog, '530') !== false || strpos($smtplog, '535') !== false || strpos($smtplog, '235') === false) { 353 | $issues .= get_string('failcredentials', 'local_' . $pluginname); 354 | } 355 | 356 | // No-reply address is probably fake or contains a typo. 357 | // Your mail server requires a real email address with a real mailbox. 358 | if (strpos($smtplog, '550') !== false) { 359 | $issues .= get_string('failunknownmailbox', 'local_' . $pluginname); 360 | } 361 | } 362 | $smtplog = '

    ' . get_string('connectionlog', 'local_' . $pluginname) . '

    ' . $smtplog; 363 | 364 | $continuelink = ($CFG->branch >= 32) ? 'outgoingmailconfig' : 'messagesettingemail'; 365 | $msg = get_string($errtype, 'local_' . $pluginname, '../../admin/settings.php?section=' . $continuelink); 366 | 367 | // Display diagnostic information, if available. 368 | if (!empty($issues)) { 369 | $title = get_string('additionalinfo', 'local_' . $pluginname); 370 | $msg .= '

    ' . $title . '

      ' . $issues . '
    ' . $smtplog; 371 | } 372 | 373 | // Also display the results of the dialogue between Moodle and the SMTP server. 374 | local_mailtest_msgbox($msg, get_string('emailfail', 'local_' . $pluginname), 3, 'errorbox', $url->out()); 375 | } else { 376 | // Failed to send message using PHPMailer. 377 | $title = get_string('emailfail', 'local_' . $pluginname); 378 | $msg = get_string('failphpmailer', 'local_' . $pluginname); 379 | local_mailtest_msgbox($msg, $title, 3, 'errorbox', $url->out()); 380 | } 381 | } 382 | 383 | // Footing =========================================================. 384 | 385 | echo $OUTPUT->footer(); 386 | -------------------------------------------------------------------------------- /lang/en/local_mailtest.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Strings for component 'local_mailtest', language 'en', branch 'MOODLE_20_STABLE' 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngconsulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die(); 27 | 28 | $string['additionalinfo'] = 'Additional information:'; 29 | $string['alwaysshowlog'] = 'Always show log of communications with mail server, even if there are no errors.'; 30 | $string['bimidmarcfailure'] = 'BIMI failure due to one or more DMARC dependency failures.'; 31 | $string['bimiinvalidlogo'] = 'Missing BIMI logo: {$a}.'; 32 | $string['biminorecordfound'] = 'BIMI record is missing.'; 33 | $string['bimipctinvalid'] = 'DMARC PCT value must be set to 100 for BIMI.'; 34 | $string['bimirecordfound'] = 'BIMI record found.'; 35 | $string['bimitagsfound'] = 'BIMI tags valid.'; 36 | $string['checkingdomain'] = 'DNS security check for {$a}:'; 37 | $string['commoncommissues'] = ' 38 |
  • Your Moodle site may be blocked by a firewall, preventing communication with your mail server.
  • 39 |
  • You may need to add the IP address of your website to a list of allowed IP addresses in your mail server\'s configuration.
  • 40 |
  • Ensure that your SMTP server is up and running.
  • 41 | '; 42 | $string['commondeliveryissues'] = 'If the email is not delivered within about 15-30 minutes, check the following:

    43 |
      44 |
    • Ensure that the TO email address is correct.
    • 45 |
    • Check the recipients spam/junk mail.
    • 46 |
    • Check the recipients mailbox to make sure it is not full.
    • 47 |
    • Check the mailbox of your no-reply email address to see if the message bounced (was not delivered) for any reason.
    • 48 |
    • Check that your email content is not being flagged as spam/junk by any filter on your mail server or on the recipient\'s mail server.
    • 49 |
    • Make sure that the IP address of your mail server is not blacklisted by any mail providers.
    • 50 | {$a} 51 |
    '; 52 | $string['connectionlog'] = 'Communications log with mail server'; 53 | $string['credit'] = 'Michael Milette - TNG Consulting Inc.'; 54 | $string['divertallemails'] = 'Divert all emails'; 55 | $string['divertedto'] = 'Diverted to {$a}'; 56 | $string['dkiminvalidrecord'] = 'DKIM record must contains valid v, k and p tags.'; 57 | $string['dkimmissingselector'] = 'DKIM selector setting has not been configured.'; 58 | $string['dkimnorecordfound'] = 'DKIM record is missing.'; 59 | $string['dkimrecordfound'] = 'DKIM record found.'; 60 | $string['dkimselectorconfigured'] = 'DKIM selector setting is configured.'; 61 | $string['dkimspffailed'] = 'DMARC requires that SPF or DKIM records be configured.'; 62 | $string['dkimvalidrecord'] = 'DKIM record format is valid.'; 63 | $string['dmarcnorecordfound'] = 'DMARC record is missing.'; 64 | $string['dmarcpctinvalid'] = 'DMARC pct value is not within range.'; 65 | $string['dmarcrecordfound'] = 'DMARC record found.'; 66 | $string['dmarcruainvalid'] = 'DMARC rua value is not formatted correctly.'; 67 | $string['dmarcrufinvalid'] = 'DMARC ruf value is not formatted correctly.'; 68 | $string['dmarctagsfound'] = 'DMARC required tags found.'; 69 | $string['emailfail'] = 'Failed to send email message'; 70 | $string['errorcommunications'] = '

    Moodle could not communicate with your mail server.

    Recommendations:

    Start by checking your Moodle SMTP mail settings.

    If they look correct, check your SMTP Server and/or firewall settings to ensure that they are configured to accept SMTP connections from your Moodle web server and your no-reply email address. For more help, see the FAQ section in the documentation.

    '; 71 | $string['errorsend'] = '

    The test email message could not be delivered to the mail server.

    Recommendations:

    Check your Moodle Email settings. For more help, see the FAQ section in the documentation. You may also wish to reference the list of SMTP codes in RFC 5321 and RFC 4954.

    '; 72 | $string['errorunknown'] = '

    An undiagnosed error occured.

    Recommendations:

    Refer to the communications log below. You may find it useful to reference the list of SMTP codes in RFC 5321 and RFC 4954.

    '; 73 | $string['failaccessdenied'] = '
  • Connect to the mail server but it closed then closed connection.
  • '; 74 | $string['failclosedport'] = 'Server port {$a} is closed. Did you specify the correct :port number?'; 75 | $string['failcredentials'] = '
  • Authentication credentials may be invalid or missing. Make sure that you have entered the correct login information.
  • '; 76 | $string['faildnslookup'] = 'DNS lookup failed. Ensure that \'{$a}\' resolves to the address of a mail server.'; 77 | $string['failmissingport'] = 'You may need to specify a :port number for "{$a}" type connections.'; 78 | $string['failmissingprotocol'] = 'You may need to specify a secure protocol type (SSL/TLS) with port \'{$a}\'.'; 79 | $string['failoutboundsmtpblocked'] = 'Something is blocking connectivity of outbound SMTP connections. Is there a firewall blocking your connection to the mail server?'; 80 | $string['failphpmailer'] = 'There may be issues with your installation of Moodle LMS. One possible reason is incorrect owner/group permissions of the application files.'; 81 | $string['failphpmailerconfig'] = 'The mail service on the your Moodle web server may not be running or may be incorrectly configured.'; 82 | $string['failprotocolmismatch'] = 'You may have a mismatch between the protocol \'{$a->protocol}\' and the port \'{$a->port}\'.'; 83 | $string['failunknownmailbox'] = '
  • The FROM mailbox was not found, is not accessible, or was rejected for policy reasons. Make sure that both the TO and FROM email addresses are valid and exist and that the \'no-reply\' address is a real mailbox that exists on your mail server.
  • '; 84 | $string['from'] = '{$a->type}: {$a->email} ({$a->label})'; 85 | $string['fromemail'] = 'From email address'; 86 | $string['heading'] = 'Email configuration test'; 87 | $string['iconlabel'] = 'Security check for {$a}'; 88 | $string['message'] = '

    This is a test message. Please disregard.

    89 |

    If you received this email, it means that you have successfully configured your Moodle site\'s email settings.

    90 |

    Additional User Information

    91 |
      92 |
    • Registration status : {$a->regstatus}
    • 93 |
    • Preferred language : {$a->lang}
    • 94 |
    • User\'s web browser : {$a->browser}
    • 95 |
    • Message submitted from : {$a->referer}
    • 96 |
    • Moodle version : {$a->release}
    • 97 |
    • User\'s IP address : {$a->ip}
    • 98 |
    '; 99 | $string['noemailever'] = '

    Email on this site has been disabled by way of $CFG->noemailever = true;.

    '; 100 | $string['nologavailable'] = '

    Logging is not available when using PHP mail() function. However, may find logs on your server. Most common locations on Linux include:

    101 |
      102 |
    • /var/log/maillog
    • 103 |
    • /var/log/mail.log
    • 104 |
    • /var/adm/maillog
    • 105 |
    • /var/adm/syslog/mail.log
    • 106 |
    107 |

    Alernatively, a custom location may be specified using the mail.log setting in php.ini.

    '; 108 | $string['notregistered'] = 'Not registered or not logged in.'; 109 | $string['phpmethod'] = 'PHP default method'; 110 | $string['pluginname'] = 'eMail Test'; 111 | $string['pluginname_help'] = 'eMail Test will verify the email settings for this Moodle site by sending a test email message to the address you specify. For Site Administrators only.'; 112 | $string['primaryadminemail'] = 'Primary admin email'; 113 | $string['privacy:metadata'] = 'The eMail Test plugin does not store any personal data about any user.'; 114 | $string['registered'] = 'Registered user ({$a}).'; 115 | $string['sendmethod'] = 'Email send method'; 116 | $string['sendtest'] = 'Send a test message'; 117 | $string['sentmail'] = 'Moodle successfully delivered the test message to the SMTP mail server.'; 118 | $string['sentmailphp'] = 'The Moodle test message was successfully accepted by PHP Mail.'; 119 | $string['server'] = 'Server: {$a}'; 120 | $string['smtpmethod'] = 'SMTP hosts: {$a}'; 121 | $string['spfinvalidrecord'] = 'SPF record must contains at least one mechanism.'; 122 | $string['spfnorecordfound'] = 'SPF record is missing.'; 123 | $string['spfrecordfound'] = 'SPF record found.'; 124 | $string['spfvalidrecord'] = 'SPF record format is valid.'; 125 | $string['testing'] = 'Testing email configuration'; 126 | $string['toemail'] = 'To email address'; 127 | $string['winsyslog'] = 'Event Log on Windows'; 128 | $string['youremail'] = 'Your email address'; 129 | -------------------------------------------------------------------------------- /locallib.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Library of functions for MailTest. 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngconsulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | /** 27 | * Generate a user info object based on provided parameters. 28 | * 29 | * @param string $email plain text email address. 30 | * @param string $name (optional) plain text real name. 31 | * @param int $id (optional) user ID 32 | * 33 | * @return object user info. 34 | */ 35 | function local_mailtest_generate_email_user($email, $name = '', $id = -99) { 36 | $emailuser = new stdClass(); 37 | $emailuser->email = trim(filter_var($email, FILTER_SANITIZE_EMAIL)); 38 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { 39 | $emailuser->email = ''; 40 | } 41 | $name = format_text($name, FORMAT_HTML, ['trusted' => false, 'noclean' => false]); 42 | $emailuser->firstname = trim(htmlspecialchars($name, ENT_COMPAT)); 43 | $emailuser->lastname = ''; 44 | $emailuser->maildisplay = true; 45 | $emailuser->mailformat = 1; // 0 (zero) text-only emails, 1 (one) for HTML emails. 46 | $emailuser->id = $id; 47 | $emailuser->firstnamephonetic = ''; 48 | $emailuser->lastnamephonetic = ''; 49 | $emailuser->middlename = ''; 50 | $emailuser->alternatename = ''; 51 | return $emailuser; 52 | } 53 | 54 | /** 55 | * Outputs a message box. 56 | * 57 | * @param string $text The text of the message. 58 | * @param string $heading (optional) The text of the heading. 59 | * @param int $level (optional) The level of importance of the 60 | * heading. Default: 2. 61 | * @param string $classes (optional) A space-separated list of CSS 62 | * classes. 63 | * @param string $link (optional) The link where you want the Continue 64 | * button to take the user. Only displays the 65 | * continue button if the link URL was specified. 66 | * @param string $id (optional) An optional ID. Is applied to body 67 | * instead of heading if no heading. 68 | */ 69 | function local_mailtest_msgbox($text, $heading = null, $level = 2, $classes = null, $link = null, $id = null) { 70 | global $OUTPUT; 71 | echo $OUTPUT->box_start(trim('box ' . $classes)); 72 | if (!is_null($heading)) { 73 | echo $OUTPUT->heading($heading, $level, $id); 74 | echo "
    $text
    " . PHP_EOL; 75 | } else { 76 | echo "
    $text
    " . PHP_EOL; 77 | } 78 | if (!is_null($link)) { 79 | echo $OUTPUT->continue_button($link); 80 | } 81 | echo $OUTPUT->box_end(); 82 | } 83 | 84 | /** 85 | * Get the user's public or private IP address. 86 | * 87 | * @return string Public IP address or the private IP address if the public address cannot be identified. 88 | */ 89 | function local_mailtest_getuserip() { 90 | $fieldlist = [ 91 | 'HTTP_CLIENT_IP', 92 | 'HTTP_X_FORWARDED_FOR', 93 | 'HTTP_X_FORWARDED', 94 | 'HTTP_FORWARDED_FOR', 95 | 'HTTP_FORWARDED', 96 | 'REMOTE_ADDR', 97 | 'HTTP_CF_CONNECTING_IP', 98 | 'HTTP_X_CLUSTER_CLIENT_IP', 99 | ]; 100 | 101 | // Public range first. 102 | $filterlist = [ 103 | FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE, 104 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE, 105 | ]; 106 | 107 | foreach ($filterlist as $filter) { 108 | foreach ($fieldlist as $field) { 109 | if (!array_key_exists($field, $_SERVER) || empty($_SERVER[$field])) { 110 | continue; 111 | } 112 | 113 | $iplist = explode(',', $_SERVER[$field]); 114 | foreach ($iplist as $ip) { 115 | // Strips off port number if it exists. 116 | if (substr_count($ip, ':') == 1) { 117 | // IPv4 with a port. 118 | $ip = explode(':', $ip)[0]; 119 | } else if ($start = (substr($ip, 0, 1) == '[') && $end = strpos($ip, ']:') !== false) { 120 | // IPv6 with a port. 121 | $ip = substr($ip, $start + 1, $end - 2); 122 | } 123 | // Sanitize so that we only get public addresses. 124 | $lastip = $ip; // But save other address just in case. 125 | $ip = filter_var(trim($ip), FILTER_VALIDATE_IP, $filter); 126 | if ($ip !== false) { 127 | return($ip); 128 | } 129 | } 130 | } 131 | } 132 | // Private or restricted range. 133 | return $lastip; 134 | } 135 | 136 | /** 137 | * Check DNS records for a given domain. 138 | * 139 | * This function checks the DKIM, SPF, DMARC, and BIMI records for a given domain. 140 | * It returns an array with a success flag and a message string. 141 | * 142 | * @param string $domain The domain to check DNS records for. 143 | * @return string Message string. 144 | */ 145 | function local_mailtest_checkdns($domain) { 146 | global $CFG; 147 | 148 | $message = ''; 149 | $success = true; 150 | 151 | $xmark = ' '; 152 | $checkmark = ' '; 153 | $exclamation = ' '; 154 | 155 | // Check SPF records. 156 | 157 | $regex = '/^v=spf1( +([-+?~]?(all|include:(%\{[CDHILOPR-Tcdhilopr-t]' 158 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 159 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 160 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\})|a(:(%\{[CDHILOPR-Tcdhilopr-t]' 161 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 162 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 163 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}))?((\/(\d|1\d|2\d|3[0-2]))?(\/\/' 164 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8]))?)?|mx(:(%\{[CDHILOPR-Tcdhilopr-t]' 165 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 166 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 167 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}))?((\/(\d|1\d|2\d|3[0-2]))?' 168 | . '(\/\/([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8]))?)?|ptr(:(%\{[CDHILOPR-Tcdhilopr-t]' 169 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 170 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 171 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}))?|ip4:([0-9]|[1-9][0-9]|1[0-9]{2}' 172 | . '|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]' 173 | . '|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]' 174 | . '|25[0-5])(\/([0-9]|1[0-9]|2[0-9]|3[0-2]))?|ip6:(::|([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|' 175 | . '([0-9A-Fa-f]{1,4}:){1,8}:|([0-9A-Fa-f]{1,4}:){7}:[0-9A-Fa-f]{1,4}|([0-9A-Fa-f]{1,4}:){6}(:' 176 | . '[0-9A-Fa-f]{1,4}){1,2}|([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,3}|([0-9A-Fa-f]{1,4}:){4}' 177 | . '(:[0-9A-Fa-f]{1,4}){1,4}|([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,5}|([0-9A-Fa-f]{1,4}:){2}' 178 | . '(:[0-9A-Fa-f]{1,4}){1,6}|[0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,7}|:(:[0-9A-Fa-f]{1,4}){1,8}|' 179 | . '([0-9A-Fa-f]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|' 180 | . '[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]' 181 | . '|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{1,4}:){6}:' 182 | . '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 183 | . '|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]' 184 | . '|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?' 185 | . '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]' 186 | . '|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 187 | . '|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}([0-9]|[1-9][0-9]' 188 | . '|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 189 | . '\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 190 | . '|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}([0-9]|[1-9][0-9]' 191 | . '|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 192 | . '\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 193 | . '|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}([0-9]|[1-9][0-9]' 194 | . '|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 195 | . '\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 196 | . '|2[0-4][0-9]|25[0-5])|[0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}([0-9]|[1-9][0-9]' 197 | . '|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])' 198 | . '\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}' 199 | . '|2[0-4][0-9]|25[0-5])|::([0-9A-Fa-f]{1,4}:){0,6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]' 200 | . '|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]' 201 | . '|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))' 202 | . '(\/(\d{1,2}|10[0-9]|11[0-9]|12[0-8]))?|exists:(%\{[CDHILOPR-Tcdhilopr-t]' 203 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 204 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 205 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}))|redirect=(%\{[CDHILOPR-Tcdhilopr-t]' 206 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 207 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 208 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\})|exp=(%\{[CDHILOPR-Tcdhilopr-t]' 209 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|[!-$&-~])*(\.([A-Za-z]' 210 | . '|[A-Za-z]([-0-9A-Za-z]?)*[0-9A-Za-z])|%\{[CDHILOPR-Tcdhilopr-t]' 211 | . '([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\})|[A-Za-z][-.0-9A-Z_a-z]*=' 212 | . '(%\{[CDHILOPR-Tcdhilopr-t]([1-9][0-9]?|10[0-9]|11[0-9]|12[0-8])?r?[+-\/=_]*\}|%%|%_|%-|' 213 | . '[!-$&-~])*))* *$/'; 214 | 215 | // Perform DNS query for SPF TXT records. 216 | $spf = false; 217 | $txtrecords = @dns_get_record($domain, DNS_TXT); 218 | // If a TXT records is found, check if it contains SPF record. 219 | if (!empty($txtrecords)) { 220 | // Check if any have the required tags. 221 | foreach ($txtrecords as $record) { 222 | if (strpos($record['txt'], 'v=spf1') !== false) { 223 | // SPF record found. 224 | $message .= $checkmark . get_string('spfrecordfound', 'local_mailtest') . '
    '; 225 | 226 | // Extract found SPF record data. 227 | $spfdata = $record['txt']; 228 | 229 | // Check if the SPF record contains at least one mechanism (mandatory). 230 | if (preg_match($regex, $spfdata)) { 231 | // SPF record contains at least one mechanism, it's valid. 232 | $message .= $checkmark . get_string('spfvalidrecord', 'local_mailtest') . '
    '; 233 | $spf = true; 234 | break; 235 | } 236 | if (!$spf) { 237 | $message .= $xmark . get_string('spfinvalidrecord', 'local_mailtest') . '
    '; 238 | } 239 | } 240 | } 241 | } 242 | // No SPF record was found. 243 | if (!$spf && empty($message)) { 244 | $message .= $exclamation . get_string('spfnorecordfound', 'local_mailtest') . '
    '; 245 | } 246 | 247 | // Check DKIM record. 248 | 249 | $dkim = false; 250 | if (empty($emaildkimselector = $CFG->emaildkimselector)) { 251 | $message .= $exclamation . get_string('dkimmissingselector', 'local_mailtest') . '
    '; 252 | } else { 253 | $txtrecords = @dns_get_record($emaildkimselector . '._domainkey.' . $domain, DNS_TXT); 254 | 255 | // If TXT records are found named *_domainkey, check if it contains DKIM record. 256 | if (!empty($txtrecords)) { 257 | // DKIM records found. 258 | $message .= $checkmark . get_string('dkimrecordfound', 'local_mailtest') . '
    '; 259 | 260 | // Check if it has the required tags. 261 | foreach ($txtrecords as $record) { 262 | // Extract DKIM record data. 263 | $dkimdata = $record['txt']; 264 | 265 | // Check if the DKIM record contains all mandatory tags. 266 | if ( 267 | strpos($dkimdata, 'v=DKIM1') !== false && 268 | strpos($dkimdata, 'k=') !== false && 269 | strpos($dkimdata, 'p=') !== false 270 | ) { 271 | // DKIM record contains all mandatory tags, it's valid. 272 | $message .= $checkmark . get_string('dkimvalidrecord', 'local_mailtest') . '
    '; 273 | $dkim = true; 274 | break; 275 | } 276 | } 277 | if (!$dkim) { 278 | $message .= $xmark . get_string('dkiminvalidrecord', 'local_mailtest') . '
    '; 279 | } else { 280 | if (empty($CFG->emaildkimselector)) { 281 | $message .= $exclamation . get_string('dkimmissingselector', 'local_mailtest') . '
    '; 282 | } else { 283 | $message .= $checkmark . get_string('dkimselectorconfigured', 'local_mailtest') . '
    '; 284 | } 285 | } 286 | } else { 287 | // Check to see if there might be a CNAME record instead. 288 | $records = @dns_get_record($emaildkimselector . '._domainkey.' . $domain, DNS_CNAME); 289 | $dkim = !empty($records); 290 | if ($dkim) { 291 | // DKIM CNAME type records can points to a DKIM key stored on another server. 292 | $message .= $checkmark . get_string('dkimrecordfound', 'local_mailtest') . '
    '; 293 | } 294 | } 295 | 296 | if (!$dkim) { 297 | // No DKIM record was found. 298 | $message .= $exclamation . get_string('dkimnorecordfound', 'local_mailtest') . '
    '; 299 | } 300 | } 301 | 302 | // Check DMARC records. 303 | 304 | $txtrecords = @dns_get_record('_dmarc.' . $domain, DNS_TXT); 305 | if (empty($txtrecords)) { 306 | // No DMARC records found. 307 | $message .= $xmark . get_string('dmarcnorecordfound', 'local_mailtest') . '
    '; 308 | $success = false; 309 | } else { 310 | // DMARC records found. 311 | $message .= $checkmark . get_string('dmarcrecordfound', 'local_mailtest') . '
    '; 312 | 313 | // Check if it has the required tags. 314 | foreach ($txtrecords as $record) { 315 | if ( 316 | preg_match('/v=DMARC1;/', $record['txt']) 317 | && preg_match('/p=(none|quarantine|reject);/', $record['txt']) 318 | ) { 319 | // Required DMARC tags are present and valid. 320 | $message .= $checkmark . get_string('dmarctagsfound', 'local_mailtest') . '
    '; 321 | 322 | // Check rua tag if present. 323 | $ruavalue = false; 324 | if (preg_match('/rua=([^;]+)/', $record['txt'], $matches)) { 325 | $ruavalue = $matches[1]; 326 | // Validate rua value format (should be a valid URI). 327 | if (!filter_var($ruavalue, FILTER_VALIDATE_URL) && !filter_var("mailto:" . $ruavalue, FILTER_VALIDATE_EMAIL)) { 328 | // The rua value is not formatted correctly. 329 | $message .= $xmark . get_string('dmarcruainvalid', 'local_mailtest') . '
    '; 330 | $success = false; 331 | } 332 | } 333 | 334 | // Check ruf tag if present. 335 | $rufvalue = false; 336 | if (preg_match('/ruf=([^;]+)/', $record['txt'], $matches)) { 337 | $rufvalue = $matches[1]; 338 | // Validate ruf value format (should be a valid URI). 339 | if (!filter_var($rufvalue, FILTER_VALIDATE_URL) && !filter_var("mailto:" . $rufvalue, FILTER_VALIDATE_EMAIL)) { 340 | // The ruf value is not formatted correctly. 341 | $message .= $xmark . get_string('dmarcrufinvalid', 'local_mailtest') . '
    '; 342 | $success = false; 343 | } 344 | } 345 | 346 | // Check pct tag if present. 347 | $pctvalue = false; 348 | if (preg_match('/pct=([0-9]+)/', $record['txt'], $matches)) { 349 | $pctvalue = intval($matches[1]); 350 | // Validate pct value range (should be between 0 and 100). 351 | if ($pctvalue < 0 || $pctvalue > 100) { 352 | // The pct value is not within the valid range. 353 | $message .= $xmark . get_string('dmarcpctinvalid', 'local_mailtest') . '
    '; 354 | $success = false; 355 | } 356 | } 357 | break; 358 | } else { 359 | // Required tags not found in any of the DMARC records. 360 | $message .= $checkmark . get_string('dmarctagsfound', 'local_mailtest') . '
    '; 361 | $success = false; 362 | } 363 | } 364 | } 365 | 366 | // Check to ensure that either DKIM or SPF is configured. 367 | if (!$dkim && !$spf) { 368 | $message .= $xmark . get_string('dkimspffailed', 'local_mailtest') . '
    '; 369 | $success = false; 370 | } 371 | 372 | // Check BIMI record. 373 | 374 | // Perform DNS query for BIMI TXT records. 375 | $txtrecords = @dns_get_record('_bimi.' . $domain, DNS_TXT); 376 | if (empty($txtrecords)) { 377 | // Required tags not found in any of the DMARC records. 378 | $message .= $xmark . get_string('biminorecordfound', 'local_mailtest') . '
    '; 379 | $success = false; 380 | } else { 381 | // Records found. Check if it has the required tags. 382 | $message .= $checkmark . get_string('bimirecordfound', 'local_mailtest') . '
    '; 383 | 384 | // Loop through each BIMI record. 385 | foreach ($txtrecords as $record) { 386 | // Extract BIMI record data. 387 | $bimidata = $record['txt']; 388 | 389 | // Check if BIMI record contains both v and l tags. 390 | if (strpos($bimidata, 'v=BIMI1') !== false && strpos($bimidata, 'l=') !== false) { 391 | // Required DMARC tags are present and valid. 392 | $message .= $checkmark . get_string('bimitagsfound', 'local_mailtest') . '
    '; 393 | 394 | // Extract logo URL from the BIMI record. 395 | preg_match('/l=([^;]+)/', $bimidata, $matches); 396 | $logourl = $matches[1]; 397 | 398 | // Validate existence of logo URL. 399 | $headers = @get_headers($logourl); 400 | if ($headers && strpos($headers[0], '200')) { 401 | // Logo URL exists, BIMI record is valid. 402 | $message .= $checkmark . get_string('bimiinvalidlogo', 'local_mailtest', $logourl) . '
    '; 403 | break; 404 | } 405 | } 406 | } 407 | if (!$success) { 408 | // Required tags not found in any of the DMARC records. 409 | $message .= $xmark . get_string('bimidmarcfailure', 'local_mailtest') . '
    '; 410 | $success = false; 411 | } 412 | if ($pctvalue != 100) { 413 | $message .= $xmark . get_string('bimipctinvalid', 'local_mailtest') . '
    '; 414 | $success = false; 415 | } 416 | } 417 | 418 | $icon = $success ? 'fa-info-circle text-info' : 'fa-exclamation-triangle text-warning'; 419 | $title = get_string('iconlabel', 'local_mailtest', $domain); 420 | $bs = ($CFG->branch >= 500 ? 'bs-' : ''); 421 | $popupicon = '' 424 | . ''; 425 | $message = '

    ' . get_string('checkingdomain', 'local_mailtest', $domain) . '

    ' . $message; 426 | $message = str_replace('{message}', str_replace('"', '"', $message), $popupicon); 427 | 428 | return $message; 429 | } 430 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | thirdparty 5 | vendor 6 | test.php 7 | 8 | -------------------------------------------------------------------------------- /pix/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-milette/moodle-local_mailtest/83f5a36a4e0b2a386d10700dff5c7d3a5e55800e/pix/icon.png -------------------------------------------------------------------------------- /pix/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-milette/moodle-local_mailtest/83f5a36a4e0b2a386d10700dff5c7d3a5e55800e/pix/logo.png -------------------------------------------------------------------------------- /settings.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Adds eMail Test link to the Site Administration > Server menu. There are no settings for this plugin. 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngconsulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die; 27 | 28 | if ($hassiteconfig) { 29 | if (!isset($CFG->branch) || $CFG->branch >= 32) { // Moodle 3.2 and later. 30 | $section = 'email'; 31 | } else { // Up to and including Moodle 3.1. 32 | $section = 'server'; 33 | } 34 | $ADMIN->add($section, new admin_externalpage('local_mailtest', 35 | get_string('pluginname', 'local_mailtest'), 36 | new moodle_url('/local/mailtest/') 37 | )); 38 | } 39 | -------------------------------------------------------------------------------- /version.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Version information for eMailTest (also called MailTest). 19 | * 20 | * @package local_mailtest 21 | * @copyright 2015-2025 TNG Consulting Inc. - www.tngconsulting.ca 22 | * @author Michael Milette 23 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die(); 27 | 28 | $plugin->component = 'local_mailtest'; // To check on upgrade, that module sits in correct place. 29 | $plugin->version = 2025042700; // The current module version (Date: YYYYMMDDXX). 30 | $plugin->requires = 2013040500; // Requires Moodle version 2.5. 31 | $plugin->release = '3.1.7'; 32 | $plugin->maturity = MATURITY_STABLE; 33 | $plugin->cron = 0; 34 | --------------------------------------------------------------------------------