I'm trying to send a mail through PHP mailer, but I'm getting this error. anyone know how to fix it, it tried multiple times but failed
Something went wrong :( PHPMailer\PHPMailer\Exception: SMTP Error: The following recipients failed: [email protected]: "Your IP: 68.65.121.178 : Your domain gmail.com is not allowed in header From" in /home/sevnowsc/howmuch.sevnstaging.website/wp/PHPMailer-master/src/PHPMailer.php:1820 Stack trace: #0 /home/sevnowsc/howmuch.sevnstaging.website/wp/PHPMailer-master/src/PHPMailer.php(1513): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Thu, 8 Oc...', '\r\n\r...') #1 /home/sevnowsc/howmuch.sevnstaging.website/wp/PHPMailer-master/src/PHPMailer.php(1352): PHPMailer\PHPMailer\PHPMailer->postSend() #2 /home/sevnowsc/howmuch.sevnstaging.website/wp/php/form.php(75): PHPMailer\PHPMailer\PHPMailer->send() #3 {main}
this is my PHP code. thank you in advance
<?php
$errorMSG = "";
// FIRST NAME
if (empty($_POST["name"])) {
$errorMSG = "Name is required ";
} else {
$name = $_POST["name"];
}
// EMAIL
if (empty($_POST["email"])) {
$errorMSG .= "Email is required ";
} else {
$email = $_POST["email"];
}
$message = $_POST["message"];
$EmailTo = "[email protected]";
$reference_id = uniqid();
$Subject = "Howmuch" . $reference_id;
$Body = "<html>
<head>
<title></title>
</head>
<body>
<div style='border: 5px solid #141348; padding:20px;'>
<h2>Person's details</h2>
<p> Full Name: $name </p>
<p>Email: $email </p>
<p>Address: $message</p>
</body>
</html>";
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
require '../PHPMailer-master/src/Exception.php';
require '../PHPMailer-master/src/PHPMailer.php';
require '../PHPMailer-master/src/SMTP.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = -1;
$mail->isSMTP();
$mail->Host = 'sevnstaging.website';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'xxxxxxxxxx';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
//Recipients
$mail->setFrom('[email protected]','How much');
$mail->addAddress($EmailTo);
$mail->addReplyTo($email);
// $mail->addCC($email);
//Content
$mail->isHTML(true);
$mail->Subject = $Subject;
$mail->Body = $Body;
$mail->AltBody = '';
$mail->send();
echo "<script type='text/javascript'>window.location.href = '../thank-you.php';</script>";
} catch (Exception $e) {
if ($errorMSG == "") {
echo "Something went wrong :( <br>";
echo $e;
} else {
echo $errorMSG;
}
}
?>