dongyin0628 2012-04-22 11:03
浏览 54
已采纳

在一个电子邮件中包含一些电子邮件

I have a classifieds website and I am making a mod which will mail my users when an ad is posted in the category and in the city where they are subscribed. Now, I have a problem. I have set this file to run once a day with cronjob. In a day, in my website are 50 ads posted per day so the user gets 50 emails a day. I want to include all the 50 emails in a single one, so the user will get 1 email, but I do not know how to do that. Ex: Each email has one link and 50 emails have 50 links. I want that the users receive only a single email which will have all the 50 links in it. I have tried so many ways, but I could not do it. Every suggestion is welcomed.

Thanks

  • 写回答

3条回答 默认 最新

  • duanli9001 2012-05-06 12:46
    关注

    simply gather your ad-information in an array, where you set the email as array-key.

    $recipients = array();
    while ($row = mysql_fetch_assoc($result)) {
      $email = $row["email"];
      if (!array_key_exists($email, $recipients)) {
        $recipients[$email] = array();
      }
      $recipients[$email][] = $row;
    }
    

    After this, you have an array and each email has a variable number of $row-entries. You just need to add these entries to your mail template using a foreach-loop.

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

报告相同问题?