For the online learning world

Elearning WorldLMSMoodleTechnical

Testing your Moodle LMS Plugin’s email functionality on Windows

Last month, we talked about how to install Moodle LMS locally on your Windows computer in order to do things like testing and experimentation (installing updates, trying out courses, trying out themes and plugins) without fear that you will break your production Moodle site. Another very useful purpose for having a local instance of Moodle LMS is for development. If you are doing development of Moodle LMS plugins or themes, a feature of many plugins is to send automated notifications by email.

One of my favourite tools in my development toolchest for testing email functionality in Moodle LMS is called Papercut SMTP. This small, light weight SMTP server and email client for Windows is free, is open source and super easy to setup and use.

Once installed, just unconfigure Moodle’s SMTP server setting and you are all set to go. All email sent by Moodle will unconditionally be sent to Papercut, even if you don’t have Internet access, because everything runs locally on your computer. Want to test sending 1000 bulk emails to different email addresses? No problem because there won’t be any email server and in-box to clutter up.

Installing Papercut SMTP

Download Papercut SMTP by Changemaker Studios. You will find the latest installation files and executables by using the link under the Releases section of the page. I recommend downloading the file called Papercut.Smtp.Setup.exe (about 3.4 MB). Once downloaded, execute Papercut.Smtp.Setup.exe to begin the installation.

Click the Install button.

Click the Next button to begin the setup wizard.

Click Next to install both the SMTP application (email client) and the SMTP service.

Click install when ready to install Papercut SMTP.

The installation is very quick. Click Finish to exit the setup wizard.

There are no settings to be configured. It is ready to use.

Configuring Moodle LMS

The next step will be to configure Moodle to communicate with the Papercut SMTP service. Note that this step is only required if you have configured the SMTP setting because, by default, no changes are necessary in Moodle.

Logged in as a Moodle Administrator on your local instance of Moodle, navigate to Site Administration > Server > Outgoing email configuration, and remove everything in the SMTP hosts field, if it is not already empty.

Do not forget to click the Save Changes button at the bottom of the page after making a change.

Try it out

Once you have completed this step, all emails sent by this instance of Moodle LMS, regardless of the email address, will be delivered to Papercut.

To test, why not use the eMailTest plugin, available for free on Moodle.org? Once the plugin is installed, just navigate to Site Administration > Server > Mail Test, complete the form and click the Send a Test Message button. On a side note, you may also find this handy plugin to be useful for troubleshooting email issues on your live production site.

It does not matter what the “To email address” is set to as the email will not actually be sent out on the Internet, just to Papercut SMTP.

To check your email, find launch Papercut in your Windows Start menu. The first time you do this, you may be prompted with a Windows Security Alert. Be sure to check the box for Private Networks and uncheck the box for Public Networks before clicking the Allow Access button.

The simple Papercut email client will appear, listing all of the emails that your Moodle site will send from this point forward. New emails should appear almost instantaneously.

I hope you find this technique useful for ensuring Moodle plugins, themes and even Moodle itself works properly. While you could achieve similar results by configuring the $CFG->divertallemailsto setting in Moodle’s config.php, that method still requires that your local instance of Moodle send email through a mail server and needlessly fill your email in-box.

Did you know? Papercut SMTP does not just work with Moodle LMS. You can actually use it with any application that sends email using PHP’s mail function.

See you next month!

Michael Milette

Michael Milette
Follow me

Michael Milette

Michael Milette is the owner and an independent consultant with TNG Consulting Inc. in Canada. He works with government, non-profit organizations, businesses and educational institutions on Moodle-related projects. Michael writes about implementing Moodle LMS, developing in Moodle, Moodle administration, using the FilterCodes plugin (his own project), creating multi-language Moodle implementations and courses, and WCAG 2.1 accessibility.

2 thoughts on “Testing your Moodle LMS Plugin’s email functionality on Windows

  • Pingback: Skills and Tools for Moodle LMS Developers - ElearningWorld.org

  • Very interesting post Michael !
    I’m not a Microsoft Windows user, but for anyone who is this looks very useful indeed.
    Mail configuration is often one of the areas that catches out new Moodle admins, who have installed their own site.
    This is an interesting facility – thanks for explaining the setup 🙂


Add a reply or comment...