角度,发送$ http帖子通过php

时间:2016-01-09 11:08:23

标签: php angularjs ionic-framework

我正试图从我的离子应用程序发送邮件。

services.js:

.service('sendToServer', [
    '$http',
    function ($http) {
        'use strict';

        this.f = function (dataToSend) {
            return $http({
                url: 'http://id:password@boardlineapp.com/app/mail.php',
                method: "POST",
                data: dataToSend
            });
        };
    }
])

controller.js:

var data = {
                            userEmail: "john@yahoo.fr",
                            subject: " dev issue: had to fallback to local DB file",
                            destEmail: "contact@us.fr",
                            body: body
                        };

                        sendToServer
                            .f(data)
                            .success(function () {
                                console.log("Message to dev successfully sent");
                            })
                            .error(function () {
                                console.log("The message to dev could not be sent...");
                            });

我从我的代码中收到消息“dev to dev successfully sent”,但我没有收到邮箱中的电子邮件。

mail.php:

<?php
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: *");
if($_POST) {
    $userEmail=$_POST['userEmail'];
    $subject=$_POST['subject'];
    $destEmail=$_POST['destEmail'];
    $body=$_POST['body'];

    mail($destEmail, $subject, $body, "From:" . $userEmail);

}
?>

0 个答案:

没有答案