【问题标题】:PHP imap, send to message id?PHP imap,发送到消息I​​D?
【发布时间】:2015-11-27 22:15:56
【问题描述】:

我正在构建一个可以阅读、回复和发送电子邮件的 php 应用程序。我使用 php imap 来检索电子邮件。每封电子邮件都有一个message-id,看起来像5981e1f444a81f1fc60549beb91ce060bc795d20@domain.co.uk。我试图用我的 php 应用程序回复这个特定的消息,但没有工作。我使用test@domain.co.uk 作为邮件服务器,我使用php imap 将电子邮件检索到我的php 应用程序。每封电子邮件都有一个 message-id,我如何回复特定的消息?我该如何解决?下面的例子不起作用。

/* try to connect */
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to email: ' . imap_last_error());

    /* grab emails */
    $emails = imap_search($inbox,'ALL');

    /* if emails are returned, cycle through each... */
    if($emails) {

        /* begin output var */
        $output = '';

        /* put the newest emails on top */
        rsort($emails);

        /* for every email... */
        foreach($emails as $email_number) {

            /* get information specific to this email */
            $overview = imap_fetch_overview($inbox,$email_number,0);
            $message = imap_fetchbody($inbox,$email_number,2);


                $headers = "From: test@plantsandtreesonline.co.uk \r\n";
        $headers .= "Reply-To: ".$overview[0]->message_id."\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $subject = "testing";
        $message = "test message2";
        wp_mail( $overview[0]->message_id, $subject, $message, $headers );

        }

        echo $output;
    } 

    /* close the connection */
    imap_close($inbox);

【问题讨论】:

    标签: php email


    【解决方案1】:

    我认为您想要“In-Reply-To:”而不是“Reply-To:”作为带有消息 ID 的标头。 “Reply-To”将是一个电子邮件地址 - 应将回复发送给谁。

    【讨论】:

      猜你喜欢
      • 2018-01-15
      • 1970-01-01
      • 2013-03-10
      • 1970-01-01
      • 2011-01-27
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多