Tag Archives: moodle error mail function

Moodle Error: Could not instantiate mail function

If you are here it is because you probably set up your moodle account and when your users tried to register, they could not login because their account was still on hold.  Also, they probably received this error and had little clue why this blocked them.

Well, this shortcoming or bug is probably a result of the restrictions placed on your space by your hosting company, for example.  At least it has been my case with GoDaddy.  Don’t get me wrong, I think overall they are a good value.  Anyway, on to the fix.

Open your class.phpmailer.php file under your moodle/lib/phpmailer folder. 

Here go to line 109 and change

     * Method to send mail: (“mail”, “sendmail”, or “smtp”).
     * @var string — Changed from mail to sendmail
    var $Mailer            = “mail”;


    var $Mailer            = “sendmail”;
Then go to line 269 and change

     * Sets Mailer to send message using PHP mail() function.
     * @return void — changed mail to sendmail
    function IsMail() {
        $this->Mailer = “mail”;

        $this->Mailer = “sendmail”;

Hopefully this should bypass using the mail() function completely.

It worked for me so I hope it works for you.



Filed under Computer - Technical