1

ユーザーのサブスクリプションが終了したときに送信される電子メール メッセージの本文にリンクを追加する必要があります。このリンクは、「ユーザー名」がサブスクリプションの更新を希望していることを示すメールをアドレスに送信する必要があります。あなたが私を理解しているなら、だから私はphp mail()の中でphp mail()をする必要があります! また、リンクをクリックすると、お礼のメッセージが表示されます。現在の「sendExpiryEmail」関数の PHP コードは次のとおりです。あなたが助けてくれることを願っています! ありがとう。

パブリック関数 sendExpiryEmail($emails){

    foreach($emails as $email){

        $name = $email['name'];

        $emailaddress = $email['email'];

        $expirydate = date('jS F Y',strtotime($email['datetime_expire']));



        $subject = "AZ China Report expiry reminder";



        $body = '<p><img src="http://az-china.com/images/azchina_logo_email.jpg"></p>

                <p>Dear '.$name.',<br /><br />

                We hope you have been enjoying your subscription to the Black China Report.<br /><br />

                We aim to meet the needs of our readers, by de-mystifying the China market, and by providing accurate, current and pertinent facts and analysis.<br />

                We have some exciting new initiatives planned in the coming months.<br /><br />

                Your Black China Report subscription will expire on '.$expirydate.'.<br /><br />

                <strong>Renewing your subscription is easy.</strong><br /><br />

                Simply click here (link to mail()) and we will send you an order form and details on how to pay.<br /><br />

                If we can be any further assistance, please do not hesitate to contact us! <br /><br />

                Yours sincerely, <br /><br />

                Tom Martin<br /><br />

                AZ China</p>';



        // multiple recipients

        $to  = $emailaddress;

        //$to = 'c23gooey@gmail.com';



        // To send HTML mail, the Content-type header must be set

        $headers  = 'MIME-Version: 1.0' . "\r\n";

        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



        // Additional headers

        $headers .= 'From: AZ China <tom.martin@az-china.com>' . "\r\n";



        // Mail it

        mail($to, $subject, $body, $headers);

    }

}
4

1 に答える 1

0

これを処理する方法は、ルックアップ テーブルまたはジャンクション テーブルをセットアップすることです。ここには、対応するユーザー ID を使用して更新要求ごとに生成する一意の識別 ID を格納します。

この表は次のようになります。

renewals
-------------------------------
renewid              | userid
-------------------------------
[output of uniqid()] | bob
[output of uniqid()] | bill
[output of uniqid()] | sarah
...

スクリプトを実行して期限切れ間近のアカウントのリストを収集する場合は、電子メール ステップに次のように少し追加します。

while ...

    $renewid = uniqid();

    $renewurl = "http://.../renew.php?req=$renewid";

    // Put that URL in the body of the email.

    $renewsql = "
INSERT INTO renewals (
    renewid, userid
) VALUES (
    '$renewid', '{$email['userid']}'
)
";

    if ($db->query($renewsql)) {
        mail(...);
    }
}

$email['userid']それがそのユーザー ID フィールドの名前であり、それを のクエリで選択したと仮定します$emails

次に、 のような URL を使用して、 で次のhttp://.../renew.php?req=$renewidようなことを行うことができますrenew.php

<?php

$renew = preg_replace('/^a-z0-9/i', '', $_GET['req']);

if ($renew != '') {
    $which = $db->query("
SELECT userid 
FROM renewals 
WHERE renewid = '$renew' 
LIMIT 1
");

    if ($which->hasRows()) {
        $userid = $which->get(0)->field('userid');

        // do whatever renewal stuff with the $userid

        $db->query("DELETE FROM renewals WHERE renewid = '$renewid'");
    } 
}

もう 1 つの方法は、expires列を追加して、古い更新要求を定期的に消去できるようにすることです。しかし多かれ少なかれ、これは一般的な考え方です。

于 2013-03-26T07:42:31.220 に答える