在Google App Engine中接收电子邮件(Codeigniter)

时间:2015-08-09 12:56:31

标签: ajax codeigniter google-app-engine

我在Google App Engine上使用codeigniter,我的应用程序收到电子邮件,解析它们并将它们存储在数据库中。

当我刷新/handling_incoming_email.php页面时,它工作正常并在数据库中存储一个空值,表明代码有效。但是,当我发送电子邮件到someone@something.appspotmail.com时,我根本没有采取任何行动。

日志会在发送电子邮件后显示此条目,表明应用会收到电子邮件,但不会触发/emailhandling_incoming_email.php

GAE日志条目:

18:10:04.382 200 1.85 KB 7ms /_ah/mail/krish@something.appspotmail.com

以下是我的代码

的app.yaml

inbound_services:
- mail

- url: /_ah/mail/.+
script: handle_incoming_email.php
login: admin

handle_incoming_email.php

<?php
include 'application/third_party/plancake_email_parser.php';
$emailParser = new PlancakeEmailParser(file_get_contents('php://input'));
$email_body = $emailParser->getBody();
?>
<script type="text/javascript" src="/static/assets/js/jquery.js">                          

     var emailBody = '<? echo $email_body; ?>';

                        $.ajax({
                                type: "POST",
                                url: "http://something.appspot.com/email", 
                                data: {body: emailBody                                             
                                       },
                                success: function(data){
                                console.log("Data sent to server");
                                }
                            });

控制器(Email.php)

class Email extends CI_Controller {


public function __construct() {
    parent::__construct();
    $this->load->helper('url');
    $this->load->library('session');
    $this->load->library('email');
    $this->load->model('tickets_model');
}



public function index() {

    $email_body = $_POST['body'];
    $result = $this->tickets_model->email_to_ticket($email_body);
}
}

我坚持了近两天没有任何突破。

0 个答案:

没有答案