以纯文本形式在文本电子邮件中发送php变量

时间:2017-11-24 23:00:49

标签: php ajax email text

我将带有Ajax的变量传递给我的php文件,然后发送普通电子邮件和文本。变量是一个像这样循环的数组:

echo "<p class='names'>" . $give. " give to ".$receiving . "</p>";

因此,它适用于我的普通电子邮件,但在SMS文本中,它显示为:

<p class='names'>A give to B . "</p>"

我希望文字版本只显示A give to B

在我的php文件中,变量写成$nameOutput = $_POST['nameOutput'];。是否有一个函数可以在文件中稍后分配给$nameOutput,在文本代码之前重写变量以仅渲染文本,但每个循环有一个换行符?

这样的事情:

A give to B

B give to C

任何人都知道这是否可行?

代码:

$nameOutput = $_POST['nameOutput'];
$email_send = $_POST['email'];
$phone      = $_POST['phone'];
$carrier    = $_POST['carrier'];

后面的代码

中的文本部分
$nameOutput = strip_tags($nameOutput, '<br>');
$to_text = $phone."@".$carrier;
$from_text = "paul@optimumwebdesigns.com";
$message = "Here are your results!" . "<br>" . $nameOutput;
$headers = "From: $from\n";
mail($to_text, '', $message, $headers);

$nameOutput呈现以下内容:

Paul & Becky give to Ashley & Jeric
Keith & Jackie give to Rob & Savannah
Dave & Lauren give to Paul & Becky
Ashley & Jeric give to Dave & Lauren
Rob & Savannah give to Keith & Jackie

最新代码:

$breaks = array("<br />","<br>","<br/>");
$nameOutput = str_ireplace($breaks, "\r\n", $nameOutput);
$nameOutput = strip_tags($nameOutput);
//$nameOutput = strip_tags($nameOutput, '\r\n');
$to_text = $phone."@".$carrier;
$from_text = "paul@optimumwebdesigns.com";
$message = "Here are your results!" . "<br>" . $nameOutput;
$headers = "From: $from\n";
$headers = "Content-Type: text/html; charset=UTF-8";
mail($to_text, '', $message, $headers);

编辑icecub:
只是为了任何未来的读者:他正在谈论纯文本短信。不是电子邮件!

0 个答案:

没有答案