:::

5-2-2 製作HTML通知信內容

您沒有觀看影片的權限

您沒有觀看影片的權限

請先登入,登入後,確認您的權限後,即可觀看影片。

  1. 建立HTML的信件內容,Gmail 可以支援的 CSS 屬性:https://developers.google.com/gmail/design/reference/supported_css
    // 產生通知信內容
    public static function mk_content($id, $head = '', $foot = '', $action = [])
    {
        if ($id) {
            $TadDataCenter = new TadDataCenter('tad_signup');
            $TadDataCenter->set_col('id', $id);
            $tdc = $TadDataCenter->getData();
    
            $table = '<table class="table">';
            foreach ($tdc as $title => $signup) {
                $table .= "
                <tr>
                    <th>{$title}</th>
                    <td>";
                foreach ($signup as $i => $val) {
                    $table .= "<div>{$val}</div>";
                }
    
                $table .= "</td>
                </tr>";
            }
            $table .= '</table>';
        }
    
        $content = "
        <html>
            <head>
                <style>
                    .table{
                        border:1px solid #000;
                        border-collapse: collapse;
                        margin:10px 0px;
                    }
    
                    .table th, .table td{
                        border:1px solid #000;
                        padding: 4px 10px;
                    }
    
                    .table th{
                        background:#c1e7f4;
                    }
    
                    .well{
                        border-radius: 10px;
                        background: #fcfcfc;
                        border: 2px solid #cfcfcf;
                        padding:14px 16px;
                        margin:10px 0px;
                    }
                </style>
            </head>
            <body>
            $head
            <h2>{$action['title']}</h2>
            <div>活動日期:{$action['action_date']}</div>
            <div class='well'>{$action['detail']}</div>
            $table
            $foot
            </body>
        </html>
        ";
        return $content;
    }

     

  2. 根據不同狀況,產生信件內容
    // 產生通知信
    public static function mail($id, $type, $signup = [])
    {
        /*--略--*/
    
        if ($type == 'destroy') {
            $title = "「{$action['title']}」取消報名通知";
            $head = "<p>您於 {$signup['signup_date']} 報名「{$action['title']}」活動已於 {$now} 由 {$name} 取消報名。</p>";
            $foot = "欲重新報名,請連至 " . XOOPS_URL . "/modules/tad_signup/index.php?op=tad_signup_data_create&action_id={$action['id']}";
        } elseif ($type == 'store') {
            $title = "「{$action['title']}」報名完成通知";
            $head = "<p>您於 {$signup['signup_date']} 報名「{$action['title']}」活動已於 {$now} 由 {$name} 報名完成。</p>";
            $foot = "完整詳情,請連至 " . XOOPS_URL . "/modules/tad_signup/index.php?op=tad_signup_data_show&id={$signup['id']}";
        } elseif ($type == 'update') {
            $title = "「{$action['title']}」修改報名資料通知";
            $head = "<p>您於 {$signup['signup_date']} 報名「{$action['title']}」活動已於 {$now} 由 {$name} 修改報名資料如下:</p>";
            $foot = "完整詳情,請連至 " . XOOPS_URL . "/modules/tad_signup/index.php?op=tad_signup_data_show&id={$signup['id']}";
        }
    
        $content = self::mk_content($id, $head, $foot, $action);
        if (!self::send($title, $content, $email)) {
            redirect_header($_SERVER['PHP_SELF'], 3, "通知信寄發失敗!");
        }
        self::send($title, $content, $adm_email);
    }

link to https://github.com/tadlearn/tad_signup/commit/6d4752f82a8206b1958b6b67128640ec70f8d1ba \


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1698%26tbsn%3D48

書籍目錄

展開 | 闔起

線上使用者

23人線上 (7人在瀏覽線上書籍)

會員: 0

訪客: 23

更多…