PHPMailer, erreur Fatale: Appel à un membre de la fonction Send() sur un non-objet

J'obtiens cette erreur PHP Fatal error: Call to a member function Send() on a non-object. Cette erreur concerne la ligne if(!$mail->Send()).

J'ai cherché sur un autre forum, et il serait peut-être à l'aide de "load->" quelque part, mais je ne suis pas sûr de savoir pourquoi et comment.

function New_Mail($email,$firstname,$surname,$body, $subject, $altBody, $wordwrap){

$mail             = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;                  //enable SMTP authentication
$mail->SMTPSecure = "ssl";                 //sets the prefix to the server
$mail->Host       = "smtp.gmail.com";      //sets GMAIL as the SMTP server
$mail->Port       = 465;                   //set the SMTP port

$mail->Username   = "[email protected]";  //GMAIL username
$mail->Password   = "xxxxx";            //GMAIL password

$mail->From       = "[email protected]";
$mail->FromName   = "Admin";

$mail->Subject    = $subject;
$mail->AltBody    =  $altBody;//Text Body
$mail->WordWrap   = $wordwrap; //set word wrap
$mail->AddAddress($email,$firstname." ".$surname);

$mail->MsgHTML($body);
$mail->AddReplyTo("[email protected]","Admin");
$mail->SMTPDebug = 1;

$mail->IsHTML(true); //send as HTML

}

$mail=New_Mail($email,$firstname,$surname,'This is the body','Welcome','this is the alternate body',100);

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
//nothing is displayed
}
InformationsquelleAutor alexx0186 | 2012-04-19