首頁  >  問答  >  主體

建立能夠包含參數的電子郵件模板

<p>我希望使用者可以建立自己的範本來發送電子郵件,並尋找可以添加自己的參數的方式,我可以捕獲參數並添加資料庫中的實際值。 </p> <p>我正在使用 Simiditor 編輯文字</p> <p>(https://i.stack.imgur.com/w0JE3.png)](https://i.stack.imgur.com/w0JE3.png)</p> <p>暫時還沒找到好的解決方法</p>
P粉575055974P粉575055974385 天前444

全部回覆(1)我來回復

  • P粉517090748

    P粉5170907482023-09-04 09:53:31

    如果我理解正確的話,您希望允許使用者使用以下參數編輯文字範本

    {clientName}
    {selectedVonderName}

    然後加入資料庫中的實際值(例如 mysql 資料)

    在這種情況下,使用 str_replace 來完成這項工作

    例如,如果您從 mysql 資料庫資料中取得數據,然後將資料指派為 $clientName$selectedVonderName,則

    <?php
    /// other code
    
    $text=".......{clientName} ....{selectedVonderName}";
    
    $text=str_replace("{clientName}", $clientName, $text);
    $text=str_replace("{selectedVonderName}", $selectedVonderName, $text);
    
    /// other code
    ?>

    回覆
    0
  • 取消回覆