我正在使用引导主题,该主题带有我的投资组合的PHP联系人表格。当我在旧的虚拟主机上使用它时,它没有问题。但是,由于我现在正在使用Siteground,因此邮件延迟到达我的收件箱,有时甚至根本没有。
根据Siteground,我必须在联系表单中使用SMTP,但是我不知道该如何使用。 你能帮我吗?
//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.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage:\n$message";
$header = "From: my@email.com\n"; // 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);
?>