duanre4421 2012-09-04 12:37
浏览 41
已采纳

Php - 消息到电子邮件地址,检索并存储在MySQL数据库中

I'm working on a system where, if a customer submits an order, they get a confirmation email. However, I'd like to make the following happen. if the customer then hits reply, and replies to this email address, I want their message to not go to that email address, but rather be stored in a MySQL database on the server.

Is there a way to 'intercept' and email in this way?

  • 写回答

6条回答 默认 最新

  • doucao1888 2012-09-04 12:40
    关注

    Have the reply to address set up to go straight into a mailbox that you can access using PHP's imap_open to access and read emails. Armed with that, it should be a simple matter to insert the data as required into a database.

    <?php
    $mbox = imap_open("{imap.example.org:143}", "username", "password");
    
    echo "<h1>Mailboxes</h1>
    ";
    $folders = imap_listmailbox($mbox, "{imap.example.org:143}", "*");
    
    if ($folders == false) {
        echo "Call failed<br />
    ";
    } else {
        foreach ($folders as $val) {
            echo $val . "<br />
    ";
        }
    }
    
    echo "<h1>Headers in INBOX</h1>
    ";
    $headers = imap_headers($mbox);
    
    if ($headers == false) {
        echo "Call failed<br />
    ";
    } else {
        foreach ($headers as $val) {
            echo $val . "<br />
    ";
        }
    }
    
    imap_close($mbox);
    ?>
    

    The full list of PHP IMAP functions is very thorough.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan