I'm using a bootstrap theme which came with a PHP contact form for my portfolio. When I used it on my old web hosting, it worked no problem. However, now that I'm using siteground, the messages arrive in my inbox with a delay, and sometimes not at all.
According to Siteground, I have to use SMTP in my contact form, but I have no idea how to do so. Would you be able to help me out?
//Removed empty($_POST['phone']) ||
$name = strip_tags(htmlspecialchars($_POST['name']));
$email = strip_tags(htmlspecialchars($_POST['email']));
//$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = "benibargera@gmail.com"; // Add your email address inbetween the "" replacing yourname@yourdomain.com - This is where the form will send a message to.
$subject = "Website Contact Form: $name";
$body = "You have received a new message from your website contact form.
"."Here are the details:
Name: $name
Email: $email
Phone: $phone
Message:
$message";
$header = "From: my@email.com
"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$header .= "Reply-To: $email";
if(!mail($to, $subject, $body, $header))
http_response_code(500);
?>