我目前正在使用PHP的通讯系统。我可以将很多电子邮件快速发送给不同的客户。PHP通讯脚本与[标签]
嗯,我想知道如何在textarea中添加[tags]
。我会将实例标记[name]
添加到我的消息中,并且旨在每个电子邮件消息的名称等于收件人的名称。
有没有人或许有一个想法如何做到这一点?
我目前正在使用PHP的通讯系统。我可以将很多电子邮件快速发送给不同的客户。PHP通讯脚本与[标签]
嗯,我想知道如何在textarea中添加[tags]
。我会将实例标记[name]
添加到我的消息中,并且旨在每个电子邮件消息的名称等于收件人的名称。
有没有人或许有一个想法如何做到这一点?
问题是有点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);
当你从数据库读取信息或模板和发送邮件,你可以使用这样的事情:
$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);
我这样解决:
第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>
';
<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>