2012-04-26 111 views
0

我目前正在使用PHP的通訊系統。我可以將很多電子郵件快速發送給不同的客戶。PHP通訊腳本與[標籤]

嗯,我想知道如何在textarea中添加[tags]。我會將實例標記[name]添加到我的消息中,並且旨在每個電子郵件消息的名稱等於收件人的名稱。

有沒有人或許有一個想法如何做到這一點?

回答

1

問題是有點wiiiide,我不確定問題是什麼,但這會做的伎倆。很明顯,你可以做很多不同的事情,但從這裏開始並按照自己的方式工作。

function getMyNewsletter($tags){ 
    $newsletter = "Hello {$tags['name']}, I hope you liked your {$tags['whattheybought']}. please buy more of my stuff!"; 
    return $newsletter; 
} 

$tags = $user->getTagsFromSomewhere(); 
$mailbody = getMyNewsletter($tags); 
yourMailer("SubjectGoesHere",$mailbody,$OtherOptions); 
1

當你從數據庫讀取信息或模板和發送郵件,你可以使用這樣的事情:

$message = 'Your HTML Message or Text with your tags like [name]'; 

// Replaces the tag [name] with the receiver name from the database 
$send_message = str_replace('[name]', $fetch['Name'], $message); 
0

我這樣解決:

第1頁:

<table> 
     <tr> 
      <td> 
       <textarea rows="11" cols="70" name="message" id="message" placeholder="your message"></textarea> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <script type="text/javascript"> 
       <!-- 
       document.write('<span id="var1" class="insert">[name]</span>, <span id="var2" class="insert">[surnaam]</span>'); 
       // --> 
       </script> 
      </td> 
     </tr> 
</table> 

第2頁:

<?php 
$message = $_POST['c_email_message']; 
$mes = $message; 
$mes = str_replace('[voornaam]',$userOb->c_user_name,$mes);                    $mes = str_replace('[achternaam]',$userOb->c_user_surname,$mes);                     


$html_inhoud = ''; 
$html_inhoud = ' 
    <table> 
     <tr> 
      <td>' . htmlentities($mes) . '</td> 
     </tr> 
    </table> 
'; 
0
<head> 
    <script type="text/javascript"> 
     function ModifySelection() { 
      var textarea = document.getElementById("myArea"); 
      if ('selectionStart' in textarea) { 
        // check whether some text is selected in the textarea 
       if (textarea.selectionStart != textarea.selectionEnd) { 
        var newText = textarea.value.substring (0, textarea.selectionStart) + 
         "[start]" + textarea.value.substring (textarea.selectionStart, textarea.selectionEnd) + "[end]" + 
         textarea.value.substring (textarea.selectionEnd); 
        textarea.value = newText; 
       } 
      } 
      else { // Internet Explorer before version 9 
        // create a range from the current selection 
       var textRange = document.selection.createRange(); 
        // check whether the selection is within the textarea 
       var rangeParent = textRange.parentElement(); 
       if (rangeParent === textarea) { 
        textRange.text = "[start]" + textRange.text + "[end]"; 
       } 
      } 
     } 
    </script> 
</head> 
<body> 
    <textarea id="myArea" cols="30" spellcheck="false">Select some text within this field.</textarea> 
    <button onclick="ModifySelection()">Modify the current selection</button> 
</body>