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

    评论

报告相同问题?

悬赏问题

  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档