Phpmailer: Could not instantiate mail function. Message could not be sent.Mailer Error: Could not instantiate mail function.

Created on 24 Sep 2015  路  4Comments  路  Source: PHPMailer/PHPMailer

example.php
error message:
"Could not instantiate mail function. Message could not be sent.Mailer Error: Could not instantiate mail function."

<?php

require  'phpmailer/PHPMailerAutoload.php';              

$mail = new PHPMailer;

$mail->SMTPDebug = 3;                               // Enable verbose debug output

// $mail->isSMTP();                                      // Set mailer to use SMTP

$mail->CharSet="iso-8859-1";
$mail->Host = 'smtp.netins.net';                      // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'myname';                    // SMTP username
$mail->Password = 'mypassword';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->addAddress('[email protected]');     // Add a recipient
$mail->addReplyTo('[email protected]');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');

// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
?>

All 4 comments

Hm, this line is commented: $mail->isSMTP(); // Set mailer to use SMTP

Please read the docs before posting, since they tell you exactly what this error means.

this is my code

<?php 
require('PHPMailerAutoload.php');
//include('class.phpmailer.php');
//require("class.smtp.php");
    if (isset($_POST['send'])) {
        $name=$_POST['name'];
        $email=$_POST['email'];
        $phone=$_POST['phone'];
        $message=$_POST['message'];
    }
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;

//$admin_email="[email protected]";

$mail->setFrom($email, $name);
$mail->addAddress("[email protected]", 'Proyo Technologies');     // Add a recipient


$mail->addReplyTo($email, $name);

$mail->isHTML(true);                                  // Set email format to HTML


$mail->Subject = 'this is subject part';
$mail->Body    = "<strong>".$name."</strong>"."<br>".$phone."<br>".$email."<br>".$message;
$mail->AltBody = 'nice job';

if(!$mail->send()) {
    echo 'Message could not be sent. ';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    header("Location: http://www.digitalseocompany.in/demo/index.php"); /* Redirect browser */
exit();
}


 ?>

and this is my result:

Message could not be sent. Mailer Error: Could not instantiate mail function.
on server

Try use $mail->isSMTP(); in server config

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aduh95 picture aduh95  路  4Comments

Synchro picture Synchro  路  6Comments

Synchro picture Synchro  路  5Comments

judodan picture judodan  路  5Comments

wilon picture wilon  路  4Comments