1

I have this error in my hostfinger domain:

Fatal error: Call to undefined method stdClass::Send() in /home/u111308831/public_html/index.php on line 26

This is my code:

<?php
//require_once('class.phpmailer.php');
require("PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = "UTF-8";
$mail->SMTPSecure = 'ssl';
$mail­->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail­->Port = 587;

$mail->From = 'sender@gmail.com';
$mail->FromName = 'Sender name';
$mail->AddReplyTo('sender@gmail.com', 'sender name');
$mail->IsHTML(true);
$mail­->Subject = "Respuestas de Pepito";
$mail->AltBody = "To view the message, please use an HTML compatible      email viewer!";
$mail->Body = "Hello";
$mail->AddAddress('receiver@gmail.com', 'receiver');

$mail­->Password = 'sender pass';
$mail->Username = 'sender@gmail.com';


if(!$mail­->Send()) {
    echo "Error al enviar: " . $mail­->ErrorInfo;
} else {
    echo "Mensaje enviado!";
}

This is my line 26: if(!$mail­->Send()) {

Do anyone knows what the problem could be? Thanks.

  • Working example here http://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer/16048485#16048485 – andrew-caulfield Feb 24 '15 at 22:39
  • Thanks. I have changed the SMTPSecure to ssl. It was the only difference between this code and mine, but I have the same error. Thanks for the comment anyway. – Luis Garcia Fernandez Feb 27 '15 at 12:06

1 Answers1

1

I think that maybe you are requiring the wrong file.

Try:

require("PHPMailerAutoload.php");
Patrick Bard
  • 1,804
  • 18
  • 40
  • and probably using an old version. – Synchro Feb 24 '15 at 22:55
  • @Synchro I am using the [master](https://github.com/PHPMailer/PHPMailer), and I got and error using `class.phpmailer.php`. Didn't know it has versions without it though. – Patrick Bard Feb 24 '15 at 22:59
  • @Synchro Also, didn't know you are the maintainer of PHPMailer. Forgive me master. – Patrick Bard Feb 24 '15 at 23:06
  • I'm new in Php and I'm not sure I'm doing all well. Now I have, in the same folder, three archives: class.phpmailer.php, PHPMailerAutoload.php (both from this link: https://github.com/PHPMailer/PHPMailer), and index.php. I comment my line like this: //require_once('class.phpmailer.php');. And I add a new line after: require("PHPMailerAutoload.php"); – Luis Garcia Fernandez Feb 27 '15 at 11:53
  • But I have the same error: "Fatal error: Call to undefined method stdClass::Send() in /home/u111308831/public_html/index.php on line 26" at the same line: "if(!$mail­->Send()) {" – Luis Garcia Fernandez Feb 27 '15 at 11:58
  • Am I doing it well? (Sorry for the three comments but I can't write a newline here) – Luis Garcia Fernandez Feb 27 '15 at 11:58