带有[tags]的PHP新闻稿脚本

时间:2012-04-26 09:34:19

标签: php newsletter

我目前正在使用PHP的时事通讯系统。我可以快速向不同的客户发送大量电子邮件。

好吧,我想知道如何在textarea中添加[tags]。我会将标记[name]添加到我的邮件中,并且每封电子邮件的名称都等于收件人的名称。

有没有人知道如何做到这一点?

4 个答案:

答案 0 :(得分:1)

这个问题有点问题,我不确定问题是什么,但这可以解决问题。很显然,你可以做很多不同的事情,但从这里开始,一路向上。

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 :(得分: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); 

答案 2 :(得分: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>
 ';

答案 3 :(得分: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>