Настройте SMTP в контактной форме PHP - PullRequest
0 голосов
/ 01 ноября 2018

Я использую тему начальной загрузки, которая поставляется с контактной формой PHP для моего портфолио. Когда я использовал его на своем старом веб-хостинге, это работало без проблем. Однако теперь, когда я использую сайт, сообщения приходят в мой почтовый ящик с задержкой, а иногда и вовсе.

Согласно 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);
  ?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...