Wysłanie emaila, kod php.

0

Witam serdecznie, chciałbym wysłać emaila do siebie poprzez formularz kontaktowy na mojej stronie. Mam zrobionego forma oraz kod php, skonfigurowałem server apache oraz wgrałem plik php do odpowiedniego folderu apach'a.

Wpisuje swój nr tel oraz treść wiadomości i następnie po kliknięciu send, przechodzi do podstrony ze skryptem. I tyle, skrypt nie wysyła nic, nie przełącza się też nic (akurat to raczej z powodu braku ustawionego przekierowania). Jak moge zdiagnozować to jak działa mój skrypt?
Dla sprecyzowania podam kod formularza oraz skryptu.

<?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "[email protected]";
    $email_subject = "Your email subject line";

    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }


    // validation expected data exists
    if( !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';


  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
    died($error_message);
  }

    $email_message = "Form details below.\n\n";


    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }


    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";

// create email headers
$headers = 'From: '."\r\n".
'Reply-To: '."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php

}
?>

<div ng-controller="FormController">
  <div class="container-fluid">
    <div class="row">
    <div class="col-sm-8">
      <form>
        <div class="form-group">
          <label for="InputNumber">Twój numer telefonu</label>
          <input type="number" class="form-control" id="InputNumber" placeholder="Numer" ng-model="user.number">
        </div>

        <div class="form-group">
          <label for="InputText">Treść emaila</label>
          <textarea type="text" rows="5"; class="form-control" id="InputText" placeholder="tresc wiadomosci" ng-model="user.email"></textarea>
        </div>
        <button type="submit" class="btn btn-default" ><a href="http://localhost/email.php">Wyślij</a></button> 
      </form>
    </div>
  </div>
  </div>
</div>

Dodam, że tworzę to we frameworku Angular 1.

0

angular i php, ciekawe połączenie

0

W takim razie co polecisz? Szczerze mówiąc nieco sie pogubiłem. Chciałbym wiedzieć co będzie optymalnei w miare proste jak na pierwszy raz z takimi sprawami.

0

a tak w ogóle lokalnie można wysyłać wiadomości? bez dodatkowego modułu? jakiego softu używasz?

0

Doradziłem się, i chciałby zrobić to w phpmailerze.
Softu tzn o jaki soft pytasz?

0

raczej jakiego środowiska używasz do testów, wamp, xaamp?

0

Apache24

1 użytkowników online, w tym zalogowanych: 0, gości: 1