PHP致命错误:调用未定义的函数

I have this script where I am trying to send an email to the users when the site's admin deletes their account(s).

I am currently doing this by user three files: adminprocess, session and mailer.

When an admin submits a username to be deleted the actions takes place in the adminprocess. php, then adminprocess.php calls the session's function (sendUserdeleted()). sendUserdeleted(0 has a reference to the mailer's class object and a function.

For better understanding I have attached the codes below doing the job.

1 Adminprocess.php

while($row = mysql_fetch_array($rel))
  {
        $email = $row['email'];
        $name = $row['name'];
  }

  $session->sendUserdeleted($name,$email);
  header("Location: ".$session->referrer);

2 session.php

function sendUserdeleted($name,$email)
{
 global $database, $form, $mailer;  //The database, form and mailer object<br/>
 $mailer->senddeleted($name,$email);
 return 0;  //New user added succesfully
}  

3 Mailer.php

class Mailer 
{


   function senddeleted($name,$email)
   {
    $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; 
        $subject = "Lab Scheduler - Account deleted!"; 
        $body = $name.",

"."Your account from our system has been deleted"<br/>
         return mail($email,$subject,$body,$from);
   }
};

/* Initialize mailer object */
$mailer = new Mailer;

?>

I don't understand why I am unable to send a mail. Whenever I select a user to be deleted and submit the value, I get the following error:

Fatal error: Call to undefined method Mailer::senddeleted() in D:\Hosting\9769324\html\lab\include\session.php on line 408

That's how the mail isn't getting sent. Though, I the user is getting deleted without any issues.

Any help would be greatly appreciated.

/* Initialize mailer object */
$mailer = new Mailer;

This should be in your session.php

require_once('Mailer.php');

function sendUserdeleted($name,$email){
    global $database, $form;  //The database, form and mailer object

    $mailer = new Mailer;
    $mailer->senddeleted($name,$email);

    return 0;  //New user added successfully
}

include Mailer.php in session.php and create an instance of mailer

add <?php include('Mailer.php') ?> in session.php

  1. Remove all the <br> from mailer.php file.

  2. Include mail.php in session.php like include("Mailer.php")

  3. Instantiate an object of mail class in session.php $mailer = new Mailer;

you have already a $mailer object in Mailer class so this should work in session.php

   include('Mailer.php');

   function sendUserdeleted($name,$email){
        global $database, $form, $mailer ;  //The database, form and mailer object


        $mailer->senddeleted($name,$email);

        return 0;  //New user added succesfully
    }