-1

I am using phpmailer without SMTP to send email from my website hosted at namecheap. Code is shown below. I am getting the error "Could not instantiate mail function." I have read out many thread here but I am unable to get my issue solved. Need help, Thanks

I have tried using

 $mail->From = $email;
 $mail->FromName = $name;

instead of $mail->SetFrom($email, $name); and vice versa. also with and without $mail->addReplyTo() function.

    <?php
    require 'phpmailer/PHPMailerAutoload.php';
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $mail = new PHPMailer();

    $mail->SMTPDebug  = 1; //for debugging
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $name = $_POST['name'];
    $date = $_POST['date'];
    $no_of_people = $_POST['NoOfPerson'];
    $package = $_POST['select-package'];
    $comment = $_POST['comment'];

    //$mail->SetFrom($email, $name);
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->addAddress("umarsattar1989@hotmail.com"); //Recipient Email
    //$mail->addReplyTo($email, "Reply");

    $Message = "Some Text Here";
    $mail->Subject = "Inquiry about ".$package." Package";
    $mail->Body = $Message;

    if(!$mail->send()) {
    $result = "Mailer Error: " . $mail->ErrorInfo;
    } //if closing
    else 
    {
        $result = "Message has been sent successfully";
    } //else closing
    } //main if closing

"Mailer Error: Could not instantiate mail function." is printing in $result variable

Jb31
  • 1,381
  • 1
  • 10
  • 19

1 Answers1

1

When using mail(), you need to have a local mail server installed. If you don’t, this is the error you get.

You’re not using SMTP at present because you have not called isSMTP().

So the solution is to install a mail server.

Alternatively, send through a remote server using SMTP.

Synchro
  • 35,538
  • 15
  • 81
  • 104