I used PHPMailer on my website and it worked for around 10 emails and then it stopped and now gives me this error:
Message could not be sent.Mailer Error: Could not instantiate mail function.
Also do I need ->IsSMTP
for personal emails?
As I said, it worked for the first 10 emails and then I got the error.
This is my suggestion.php
:
ini_set('display_errors', 1);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim(filter_input(INPUT_POST,"name",FILTER_SANITIZE_STRING));
$email = trim(filter_input(INPUT_POST,"email",FILTER_SANITIZE_EMAIL));
$details = trim(filter_input(INPUT_POST,"details",FILTER_SANITIZE_SPECIAL_CHARS));
if ($name == "" || $email == "" || $details == "") {
echo "Please fill in the required fields: Name, Email and Details";
exit;
}
if ($_POST["address"] != "") {
echo "Bad form input";
exit;
}
require("inc/phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
if (!$mail->ValidateAddress($email)) {
echo "Invalid Email Address";
exit;
}
//$mail->IsSMTP();
$email_body = "";
$email_body .= "Name: " . $name . "<br>";
$email_body .= "Email: " . $email . "<br>";
$email_body .= "Customer Question: " . $details . "<br>";
$mail->setFrom($email, $name);
$mail->addAddress('arisconstantinou@cytanet.com.cy', 'Author'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Customer Question ' . $name;
$mail->Body = $email_body;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
header("location:suggest.php?status=thanks");
}
?>