Giter Club home page Giter Club logo

michael-milette / moodle-local_mailtest Goto Github PK

View Code? Open in Web Editor NEW
19.0 7.0 12.0 136 KB

Moodle MailTest 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. For premium support, contact us at https://www.tngconsulting.ca/contact

Home Page: https://moodle.org/plugins/local_mailtest

License: GNU General Public License v3.0

PHP 100.00%
hacktoberfest moodle moodle-plugin moodle-local

moodle-local_mailtest's Introduction

Local eMailTest plugin for Moodle

PHP Moodle GitHub Issues Contributions welcome License

Table of Contents

Basic Overview

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.

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.

(Back to top)

Requirements

This plugin requires Moodle 2.5+, 3.x+ or 4.x+ from https://moodle.org

(Back to top)

Download eMail Test for Moodle

The most recent STABLE release of eMail Test for Moodle is available from: https://moodle.org/plugins/local_mailtest

The most development release can be found at: https://github.com/michael-milette/moodle-local_mailtest

(Back to top)

Installation

Install the plugin, like any other plugin, to the following folder:

/local/mailtest

See https://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins.

There are no special considerations required for updating the plugin.

(Back to top)

Usage

There are no configurable settings for this plugin at this time.

The local_mailtest plugin is designed allow administrators to test Moodle to ensure the email message system is correctly configured.

Once installed, login as a Moodle administrator and then click:

Home > Site Administration > Server > eMail Test

Enter the email address of the recipient where you want to send the message and click the [Send a test message] button.

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.

(Back to top)

Updating

There are no special considerations required for updating the plugin.

The first public BETA version was released on 2015-11-01. This plugin is now considered STABLE.

For more information on releases since then, see CHANGELOG.md.

(Back to top)

Uninstallation

Uninstalling the plugin by going into the following:

Home > Administration > Site Administration > Plugins > Manage plugins > eMail Test

...and click Uninstall. You may also need to manually delete the following folder:

/local/mailtest

(Back to top)

Limitations

There are no known limitations at this time.

(Back to top)

Language Support

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.

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/

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:

https://github.com/michael-milette/moodle-local_mailtest

(Back to top)

FAQ

Frequently Asked Questions

Why do I get a 500 server error when I use eMailTest?

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.

Why does it say that Moodle sent the test message successfully yet I did not receive the email?

This could be due to a number of reasons including but not limited to:

  • Incorrect PHP Mail settings in your php.ini file (if you have not configured Moodle's SMTP settings).
  • You may have an anti-virus or firewall blocking email communications.
  • The mail server receiving your email may be discarding emails received from your site.
  • The test email may be blocked by anti-spam filters. Check your junk mail folder.

How do I find out the correct email settings I should be using?

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.

Why is the test emails not being sent successfully?

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.

What is the difference between PHP Mail and Moodle SMTP Mail?

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.

How can I use this tool to send emails from other email addresses?

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:

  • Your user account
  • Support
  • No-reply
  • Primary admin

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?

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.

Why do I see a message about cron not having run for at least 24 hours?

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.

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.

Why do I see some debugging code in the communications log even though debugging is turned off?

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.

Regardless of which "from" email address I use, the test email always arrives from the same email address. Why?

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.

I am not sure if the problem is with Moodle, my mail server or my firewall. What should I do?

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.

How can I use Gmail to send SMTP emails from Moodle?

Gmail requires that you create an App Password to send email for Moodle.

For more details as well as some of the limitations, see the Moodle documentation on Email Setup Gmail.-

All the settings seem to be correct. What else can I try?

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

Are there any security considerations?

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.

Other questions

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:

https://github.com/michael-milette/moodle-local_mailtest/issues

(Back to top)

Contributing

If you are interested in helping, please take a look at our contributing guidelines for details on our code of conduct and the process for submitting pull requests to us.

Contributors

Michael Milette - Author and Lead Developer

Pending Features

Let us know if you have any suggestions.

(Back to top)

Motivation for this plugin

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.

(Back to top)

Further information

For further information regarding the local_mailtest plugin, support or to report a bug, please visit the project page at:

https://github.com/michael-milette/moodle-local_mailtest

(Back to top)

License

Copyright © 2015-2024 TNG Consulting Inc. - https://www.tngconsulting.ca/

This file is part of MailTest/eMailTest for Moodle - https://moodle.org/

eMailTest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

eMailTest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with eMailTest. If not, see https://www.gnu.org/licenses/.

(Back to top)

moodle-local_mailtest's People

Contributors

danowar2k avatar michael-milette avatar michaelmeneses avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-local_mailtest's Issues

error 404

Hi,
I installed the plugin on a Moodle Moodle 3.11.5 (Build: 20220117)
When I run admin/sever/email/ eMail Test
I have this page :-(

Not Found

The requested URL was not found on this server.

same result with

  • from moodle plugin database
  • from this git repo

Could you help me ?

Feature Request: Improvements for "Connection Failed"

Prerequisites

  • I am requesting the new feature to the correct repository.
  • I checked the latest version on GitHub and the README.md documentation to ensure that this functionality does not already exist.
  • I searched to make sure that this feature has not already been requested.
  • I have, or I know someone who has, the ability and willingness to test the new feature on a Moodle LMS-based site.
  • I agree to submit one feature request per issue ticket (do not submit multiple requests in one issue ticket).
  • I understand that development and support is provided by volunteer(s) and that all final implementation decisions are up TNG Consulting Inc.

Feature Request - The User Story

David McNab suggested the following on 2023-08-12 at 17:19

Hi Michael, thanks for your efforts in maintaining the eMail Test plugin.

I had a struggle getting Moodle's inbuilt SMTP client working with my mail server, and wasn't able to get much feedback from eMail Test, apart from "Connection Failed". I had to tail the server logs, and even stage a simulated server, to see what was going wrong.

There are numerous factors which can cause the "Connection Failed". Some are:

(i) DNS lookup failure
(ii) server's port is closed
(iii) connectivity barrier such as ISP blocking outbound SMTP connections
(iv) SSL certificate non-verifiable (eg self-signed)
(v) SSL certificate invalid (eg required domain not included),
(vi) SSL certificate expired.
(vii) I also noticed the client disconnects if the 220 greeting from the server mentions a different domain name to the one configured into the Moodle client.

I don't know how much time/interest you have available for improving the eMail Test plugin, but anything you could add to shine more light on connection failures would be a big boost to users if they get stuck. It's even possible for the plugin to execute lower-level commands such as 'openssl s_client -connect mail.myserver.com:25 -starttls smtp' to drill down into certificate issues.

Other opportunities for adding value to the eMail Test plugin could be some logic to automatically attempt several permutations of ports, security methods and login methods, to seek a permutation that works. That, and the ability to configure Moodle to accept self-signed certificates case by case.

Just some thoughts anyway. I know you're probably busy so it's understandable if it's difficult to prioritise work on eMail Test. I'd probably volunteer to help out on it myself, but I'm more of a Python specialist and under the pump myself with my own projects.

Cheers
David

Screenshots / Mock-ups

No response

Alterative you have considered

No response

Additional information

No response

Planning on submitting a solution in a pull request (PR)?

Yes

Code of Conduct

PHP 7.1 Support

I noticed in your readme that php7 support was unconfirmed.

I can confirm that this plugin works with PHP 7.1 in 3.2.2+ (Build: 20170421).

Feel free to close when you receive this.

Add bulk email test

Hi Michael,

Would you consider adding a new feature to send bulk emails through a server? I am attempting to do some load tests through our SMTP server to make sure we aren't getting rate limited and having a bulk option would be great.

[1.4.0] Bug: "Notice: Undefined variable: cronoverdue in /moodle/application/htdocs/moodle/eval/local/mailtest/index.php on line 124"

Just tested 1.4.0 in my test installation.

In this line:

if ($cronoverdue) { // Cron is overdue.

Likely due to the fact that $cronoverdue is only defined in the if-scope

$cronoverdue = ($lastcron < time() - 3600 * 24);
and not in the else-scope (
if ($CFG->branch >= 27) { // Moodle 2.7+.
$sql = 'SELECT MAX(lastruntime) FROM {task_scheduled}';
} else {
$sql = 'SELECT MAX(lastcron) FROM {modules}';
}
$lastcron = $DB->get_field_sql($sql);
if ($cronoverdue) { // Cron is overdue.
).

[BUG] Notice: Undefined property: stdClass::$branch in /local/mailtest/settings.php

Prerequisites

  • I'm reporting the issue to the correct repository.
  • I am running the latest version of this plugin (if not, please upgrade first).
  • I checked the README.md and Wiki documentation but found no answer.
  • I searched to make sure that this issue has not already been reported.
  • I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site.
  • I agree to submit one bug report per issue ticket (do not submit multiple bugs in one issue ticket).
  • I understand that support is provided by volunteer(s).

What happened?

I get the following in Moodle if the eMailTest plugin files are copied into place before initial Moodle installation and debugging is enabled:

Notice: Undefined property: stdClass::$branch in /local/mailtest/settings.php on line 29

What do you think should have happened?

The case where the $CFG->branch variable has yet to be defined should have been handled better.

Steps to reproduce

  1. Complete the normal installation steps to creating a Moodle site.
  2. During the installation, you will see the following error:

Notice: Undefined property: stdClass::$branch in /local/mailtest/settings.php on line 29

Screenshots

No response

Moodle version

3.11.7

Installed Moodle UI Language packs.

  • English only

Code of Conduct

Please make version.php plain data only

Things like $plugin->release = '0.1 (Build: '.$plugin->version.')'; are not good in version.php. There are tools that parse the file as plain data, without actual PHP processing. You could easily end up with unexpected release recorded.

I would even recommend not to repeat the plugin version. Use plain "0.1" etc for the release info.

eMail Test working but Cron task not sending Forum mails

eMail Test is working fine. But Forum emails are not being sent.
Cron task runs, but emails are just queued and not send.
Does eMail Test covers mod_forum\task\cron_task or is it another mailing procedure?

Thank you

Note: Moodle 3.7.1+ (Build: 20190801)

Request: Add git tags for older versions

Hi, would you be so kind to add tags for older releases on Github?

For example, we have the 1.2.1 version running locally and are looking to update to 1.4.0, so we try to compare the two releases by tags on Github. But only the 1.4.0 tag is present.

Here's the command with which you could add the tag for the 1.2.1 commit, for example...

git tag -a "v1.2.1" 8389708abca355f46ad9e28679415488fb07c88f -m "OPTIONAL_ADDITIONAL_INFO"

Installation aborted due to validation failure

Is this now failing due to the GDPR privacy plugin?


Validating local_mailtest ... Error
  [Error] Write access check [/var/www/html/local] 
Installation aborted due to validation failure

Uses deprecated textlib static method

According to lib/upgrade.txt, all the textlib::* calls should be replaced with core_text::* since Moodle 2.6. If you want to maintain a single branch of the plugin, you may wish to use something like this in your index.php (not tested):

if ($CFG->branch >= 26) {
    $toemail = core_text::strtolower($data->recipient);
} else {
    $toemail = textlib::strtolower($data->recipient);
}

Because of the textlib, the plugin fails to work in recent Moodle 2.9 (I am aware that it is not declared as a supported version yet. I tried it out just for curiosity):

Fatal error: Class 'textlib' not found in local/mailtest/index.php on line 90

Error core_plugin / err_removing_unknown_plugin and 502

Hi,

After installation in the mailTest plugin compatible with a version of Moodle 3.0 in production. An installation error occurred and was promptly removed, but ... (core_plugin / err_removing_unknown_plugin) and when we try to access moodle, mainly on the plugin overview page, it presents the following errors.
Example:
**An error 502 occurred:
The proxy server received an invalid response from an upstream server.
The proxy server was unable to handle the GET request /moodle/admin/index.php.

Reason: Error reading from remote server

Apache / 2.4.7 server (Ubuntu) at www.xxxx.xxxx.xxx.xxx.br Port 80**

After this error, ADMIN access to Moodle is unstable. Any idea what it might be?

I didn't find any error similar reports using the plugin so I found it interesting to post here and check if help is possible.

Thank You!

From address left empty on test email

I am trying to send a test email, but the "From" is left empty. This causes the email to fail. I have chosen our no-reply email for the "From" from the first step, but it isn't being used. Is this a bug with the plugin or something in Moodle?

2017-02-15 13:35:16 SERVER -> CLIENT: 354 Start mail input; end with .
2017-02-15 13:35:16 CLIENT -> SERVER: Date: Wed, 15 Feb 2017 08:35:12 -0500
2017-02-15 13:35:16 CLIENT -> SERVER: To: [email protected]
2017-02-15 13:35:16 CLIENT -> SERVER: From: ""
2017-02-15 13:35:16 CLIENT -> SERVER: Subject: Test Email

Error in Moodle 2.4 to 3.9: Missing divertallemails string

Invalid get_string() identifier: 'divertallemails' or component 'local_mailtest'. Perhaps you are missing $string['divertallemails'] = ''; in /local/mailtest/lang/en/local_mailtest.php?
line 353 of /lib/classes/string_manager_standard.php: call to debugging()
line 7401 of /lib/moodlelib.php: call to core_string_manager_standard->get_string()
line 144 of /local/mailtest/classes/mailtest_form.php: call to get_string()
line 214 of /lib/formslib.php: call to mailtest_form->definition()
line 84 of /local/mailtest/index.php: call to moodleform->__construct()

Bug: PHP 8.1 - Constant FILTER_SANITIZE_STRING is deprecated in local/mailtest/locallib.php

Prerequisites

  • I'm reporting the issue to the correct repository.
  • I am running the latest version of this plugin (if not, please upgrade first).
  • I checked the README.md and Wiki documentation but did not find my answer.
  • I searched to make sure that this issue had not already been reported.
  • I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site.
  • I am submitting no more than one bug report per issue ticket (please do not submit multiple bugs in one issue ticket).
  • I understand that support is provided by volunteer(s).

What happened?

When I navigate to Site Administration > Server > Email Test, I get the following error message:

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in <b>local/mailtest/locallib.php on line 42

What do you think should have happened?

I expected there to be no deprecation notice.

Steps to reproduce

  1. Login as a Site Administrator
  2. Go to Site Administration > Server > Email Test

Screenshots

No response

Moodle version

Moodle 4.2

Installed Moodle UI Language packs.

  • English only
  • One or more other languages/regional dialects (specify below)
  • Other

If other language(s), please specify

No response

Workaround

No response

Additional information

No response

System information

Server PHP: 8.1

Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.