通过ionic 2使用php发送邮件

通过ionic 2使用php发送邮件,php,angularjs,ionic2,Php,Angularjs,Ionic2,我正在用ionic 2和angular 2制作一个应用程序,我用php制作了一个邮件表单。现在,我如何让我的应用程序使用我的php文件发送邮件表单 这是我的html <ion-header> <ion-navbar> <ion-title>Mail</ion-title> </ion-navbar> </ion-header> <ion-content padding> <io

我正在用ionic 2和angular 2制作一个应用程序,我用php制作了一个邮件表单。现在,我如何让我的应用程序使用我的php文件发送邮件表单

这是我的html

<ion-header>

  <ion-navbar>
    <ion-title>Mail</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>

  <ion-list>
    <form id="mailform" action="mailform.php" method="post">
      <ion-item>
        <ion-input type="text" id="naam" placeholder="Naam"                                         required="required" pattern="\D*"></ion-input>
  </ion-item>

  <ion-item>
    <ion-input type="text" id="voornaam" placeholder="Voornaam" required="required" pattern="\D*"></ion-input>
  </ion-item>

  <ion-item>
    <ion-input type="text" id="email" placeholder="Email" required="required" pattern="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$">    </ion-input>
  </ion-item>

  <ion-item>
    <ion-select placeholder="Onderwerp" required="required">
      <ion-option id="Bug">Bug</ion-option>
      <ion-option id="FouteInfo">Foute info</ion-option>
    </ion-select>
  </ion-item>

  <ion-item>
    <textarea id="text" id="text" type="text" rows="5" placeholder="Vertel ons het probleem" required="required"></textarea>
  </ion-item>


        <a (click)="send()" ion-button color="primary" icon-left>
          <ion-icon name="at" (click)="send"></ion-icon>
          Verstuur
        </a>

    </form>
  </ion-list>

</ion-content>

邮寄
缺陷
福特信息
维斯图尔
这是我的php文件

<ion-header>

  <ion-navbar>
    <ion-title>Mail</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>

<?php


$ok = false;

if (preg_match("/\D*/", $_POST["naam"])){
    $naam = true;
}
else {
    echo "Naam niet goed <br/>";
}

if (preg_match("/\D*/", $_POST["voornaam"])){
    $voornaam = true;
} 
else {
    echo "Voornaam niet goed <br/>";
}

if(isset($_POST['bug'])){
    $bug = true;
}
else {
    $bug = false;
}

if(isset($_POST['fouteInfo'])){
    $fouteInfo = true;
}
else {
    $fouteInfo = false;
}

if (preg_match("/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/",      $_POST["email"])){
    $email = true;
}
else {
    echo "email adres niet correct <br/>"
}

if (!empty($_POST["text"])){
    $text = true;
}
else {
    echo "text invullen aub <br/>";
}



if ($naam && $voornaam && $email && $text && ($bug || $fouteInfo)) {
    $ok = true;
}

        //Bericht voor admin
     $to = "anthony.gesquiere@student.vives.be";
     //$to = $_POST['email'];

     if($bug){
         $subject = "Bug";
     }
     else {
         $subject = "Foute Info";
     }

     $message = "Naam: " . $_POST['naam']  . $_POST['voornaam'] . "<br/>     Email: " . $_POST['email'] .  "<br /> Bericht: " . $_POST['text'];

     $header = "From: Stad Kortrijk <noreply@kortrijk.be> \r\n";
     $header .= "MIME-Version: 1.0\r\n";
     $header .= "Content-type: text/html\r\n";

     $retvalAdmin = mail($to,$subject,$message,$header);

        //Bericht voor gebruiker
     $to = $_POST['email'];
     $subject = "Bedankt voor uw melding";

     $message ="<h1>Bedankt ". $_POST['naam'] . " " . $_POST['voornaam'] . "   </h1> <br/><br> We zullen dit probleem zo spoedig mogelijk trachten op te lossen     <br>Met vriendelijke groeten <br> Stad Kortrijk <br/>";

     $header = "From: Stad Kortrijk <noreply@kortrijk.be> \r\n";
     $header .= "MIME-Version: 1.0\r\n";
     $header .= "Content-type: text/html\r\n";

     $retval = mail($to,$subject,$message,$header);


     if( $retval == true )
     {
        echo "Bedankt voor uw aanvraag";
     }
     else
     {
        echo "Er is een fout opgetreden, uw aanvraag werd niet verstuurd, excuses voor dit ongemak. ";
     }
  }
  else {
      var_dump($_POST);
  }


?>

</ion-content>

邮寄
现在,我该如何工作,以便我的应用程序向运行php文件的服务器发送http post请求,从而发送邮件表单