0

電子メールが送信されると、各人にX回電子メールが送信されました。次に例を示します。

Bob、Susan、Joe はすべて非アクティブなサイトを持っていました。

事がループしたとき、ボブに電子メールを送信しましたが、電子メールの本文はすべて3人の電子メールでした.

私は何を間違えましたか?

使用$body .=してメール送信後に設定を解除しなかったためでしょうか?

これが私のコードです:

$query = mysql_query("SELECT * FROM `sites` WHERE `active` = '1' AND `banned` = '0'", $link);
while ($result = mysql_fetch_array($query)){


$time = time();
$adayago = $time - 86400;
$logQ = mysql_query("SELECT * FROM `logs` WHERE `site` = '" . $result['id'] . "' AND `type` = 'in' AND `time` > '" . $adayago . "'", $link);
$logR = mysql_fetch_array($logQ);
$logNR = mysql_num_rows($logQ);


if ($logNR > 1){
    // has sent a visit in the last 24 hours
    // do nothing
}else{
    // has not send a visit in the last 24 hours
    $userQ = mysql_query("SELECT * FROM `users` WHERE `id` = '" . $result['owner'] . "'", $link);
    $userR = mysql_fetch_array($userQ);
    mysql_query("UPDATE `sites` SET `active` = '0' WHERE `id` = '" . $result['id'] . "' LIMIT 1", $link);

    $subject = "[ALERT] Your MySite.com listing has been deactivated!";
    $body .= "Hi there,\n\n";
    $body .= "Your listing for " . $result['url'] . " has been deactivated.\n\n";
    $body .= "Your listing has been deactivated because you have not received any votes within the last 24 hours.\n\n";
    $body .= "You must add our button, our link or integrate our vote link into your site and get your members to vote on your topsite listing. Doing this will allow you to stay as an active listing and receive traffic from us.\n\n";
    $body .= "If you have forgotten how to send your members to your vote link, you can visit this page: http://www.mysite.com/vote-details/" . $result['id'] . ".html to learn how to do it.\n\n";
    $body .= "If at any time you need help, please just reply to this e-mail, we are available 12 hours a day, 7 days a week. We would be happy to assist you with setting your vote link up on your website.\n\n";
    $body .= "Kind regards,\nKyle R - MySite CEO\nhttp://www.mysite.com";

    $newPostmark = new Mail_Postmark();
    $newPostmark->addTo($userR['email'], "TGDb Member")
                ->subject($subject)
                ->messagePlain($body)
                ->send();
}

}

4

2 に答える 2

1

はい。それで合っています。次のように、ループの先頭で $body をリセットするだけです。

...
while ($result = mysql_fetch_array($query)){
  $body = '';
  ...

これにより、$body が初めて追加されたときの E_NOTICE エラーも回避できます。

于 2010-12-03T15:24:32.057 に答える
1

はい、これを変更します$body .= "Hi there,\n\n";

$body = "Hi there,\n\n";
于 2010-12-03T15:25:02.420 に答える