0
function sendMail($to,$subject,$message)
{
    require_once('includes/class.phpmailer.php');

    $mail = new PHPMailer(); // create a new object
    //$mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;
    //$mail->SMTPSecure = 'ssl';
    $mail->Host = "mail.nanyanglaw.com";
    $mail->Port = 25;
    $mail->IsHTML(false);
    $mail->Username = "xxx@xxx.com";
    $mail->Password = "xxx";
    $mail->SetFrom("xxx@xxx.com","e-Voucher");
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->AddAddress($to);

    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo.'<br>';
        echo "Host: " . $mail->Host.'<br>';
        echo "Port: " . $mail->Port.'<br>';
    }
    //else
    //  echo "Message has been sent";
}

I keep getting this error, after migrating to a new server. Was working fine on the last server using the same code. I tried enable $mail->IsSMTP(), but the page stop running all together and shows no error, total blank screen.

I've checked the error log but find nothing there.

UPDATE: Found out that the class.mail.php went missing during the migration. Thanks for the help.

Alan Chan
  • 21
  • 3
  • Other related links: [one](http://stackoverflow.com/questions/1297084/phpmailer-error-could-not-instantiate-mail-function), [two](http://stackoverflow.com/questions/30648462/phpmailer-error-could-not-instantiate-mail-function). – aynber May 05 '17 at 14:13

1 Answers1

0

You should install a SMTP server, something like Postfix

Boubouh Karim
  • 448
  • 1
  • 8
  • 21