Hi everyone, tried to send email from localhost using smtp mail function but unable to do so. The error is "Could not instantiate mail function. Mailer Error: Could not instantiate mail function." Appreciate if you could advise how to solve this issue? Thanks.
require_once "PHPMailerAutoload.php";
$name = $row['name'];
$email=$row['email'];
echo $email;
echo $name;
$mail = new PHPMailer;
//Enable SMTP debugging.
$mail->SMTPDebug = 2;
//Set PHPMailer to use SMTP.
//ail->isSMTP();
//Set SMTP host name
$mail->Host = "localhost";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "smtp_username";
$mail->Password = "smtp_password";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 25;
$mail->From = ($row['email']);
$mail->FromName = ($row['username']);
$mail->addAddress("sophia@gmail.com", "Sophia");
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}