dongxiang3205 2013-01-30 12:18
浏览 93

如何使用Mailgun解析电子邮件?

by refering this article, I tried to parse the email, but i am failing to do it.

I have created free-account on mailgun, created domain, mailbox, etc. I sent one mail from my personal email ID to say, mgtest1@my_domain_name.mailgun.com

I have configured the account to forward all mails to "http://project_name/controller_name/action_name" (in case of zend) OR

"http://localhost/project_name/file_name.php" (for plain PHP)

It is said that I can access the mail using $_POST (for PHP), but I am getting blank array.

Where I am going wrong ?

I tried with both Zend and plain PHP. I am simply using print_r($_POST).

  • 写回答

2条回答 默认 最新

  • douningchang3610 2013-02-05 20:01
    关注

    print_r() is used for printing to the screen. Since the web hook handler is posting to your script, the handler saw the posted data, but you didn't. ;)

    You should store the data by serializing the array and storing it in a file.

    <?PHP
    $data = serialize($_POST);
    $fp = fopen('data.txt', 'w');
    fwrite($fp, $data);
    fclose($fp);
    ?>
    

    OR access the data directly:

    <?PHP
    $data = $_POST['recipient'];
    $fp = fopen('data.txt', 'w');
    fwrite($fp, $data);
    fclose($fp);
    ?>
    

    Hope that helps! Come chat with us, or send us a ticket, if you still have trouble.

    Thanks!
    Travis S
    Mailgun Support

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?