Disable emails in Moodle

For Moodle development I occasionally clone a production environment to a temporary test location. This way I know for certain that my custom code works in the environment it should work in.

The downside of this approach is that notifications are still mailed to users. So after a bit of searching in the Moodle docs I have found no solution. So I went digging in the code, and found a configuration option that prevents the Moodle installation to send emails completely. All you have to do is put the following setting in your config.php.
$CFG->noemailever = true;

Tip: A lot of settings are also described in the config-dist.php file in the root folder of your Moodle installation.

2 comments

  1. another option, if you still want to be able to test the mail functions, it this setting;

    // Divert all outgoing emails to this address to test and debug emailing features
    $CFG->divertallemailsto = ‘root@localhost.local’;

Leave a Reply to Doge Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.