用ionic和php脚本发送电子邮件的问题

时间:2019-01-07 10:02:19

标签: ionic-framework ionic3

我有一个问题,我正在尝试通过usign ionic 3和php脚本发送电子邮件

飞机要在其上发送发送电子邮件的名字;

我成功发送了电子邮件,但字段为“我为空”(没有随电子邮件一起发送)

这是php脚本:

<?php
require_once __DIR__ . '/connect.php';
require 'phpmailer/PHPMailerAutoload.php';


//PHPMailer Object
$mail = new PHPMailer;

//From email address and name
$mail->From = "xxx.xx@xxx.com";
$mail->FromName = "Full Name";

//To address and name
$mail->addAddress("xxx.xx@xxx.com", "Recepient Name");
//Recipient name is optional

//Address to which recipient will reply
$mail->addReplyTo("xxx.xx@xxx.com", "Reply");

//CC and BCC
$mail->addCC("xxx.xx@xxx.com");
$mail->addBCC("xxx.xx@xxx.com");

//Send HTML or Plain Text email
$mail->isHTML(true);

$mail->Subject = "Subject Text";
$mail->Body = "<p>Name :".utf8_encode(htmlentities($_POST['name'], 
ENT_QUOTES, "UTF-8"))."</p>";
$mail->AltBody = "This is the plain text version of the email content";

if(!$mail->send()) 
{
echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
echo "Message has been sent successfully";
}

这是发送方法(sendEmail.ts)

EnvoyerMSG(){

var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json' );
const requestOptions = new RequestOptions({ headers: headers });

let body = new FormData();
body.append("name","test");

this.http.post("http://android.transatour.ma/contact.php", body, requestOptions)
  .subscribe(data => {
    console.log(data['_body']);
   }, error => {
    console.log(error);
  });
  }

see the image

0 个答案:

没有答案