简体   繁体   English

如何从发送电子邮件中删除特定数据

[英]How to remove specific data from sending email

I am working on php form which will collect OID and will sent as email from a device and its working fine, I need assistance only for removing some specific data, ex: if specific OID is not available my variable will detect as "Not available" and I am receiving email as the same. 我正在使用php表单进行工作,该表单将收集OID并以电子邮件形式从设备发送并正常工作,我只需要删除某些特定数据即可获得帮助,例如:如果特定的OID不可用,我的变量将检测为“不可用”和我一样收到电子邮件。 is it possible to search and remove "Not available" word from my form before sending as email. 在通过电子邮件发送之前,是否可以从我的表单中搜索并删除“不可用”一词。

from below code kindly assume that "$FaultNo002" detect as Not available. 从下面的代码中,请假定“ $ FaultNo002”检测为“不可用”。

<?php

require 'PHPMailer-master/PHPMailerAutoload.php';

$FaultNo001 = $_POST['FaultNo001'];
$FaultNo002 = $_POST['FaultNo002'];



$body = "
<html>
<body>
<table width='750' border='0'>
  <tr>
    <td colspan='2'><h1>&nbsp;Fault Codes</h1><hr></td>
    </tr>
  <tr><td>
  ".$FaultNo001."
  ".$FaultNo002."

  </td></tr>
  </table>
</body>
</html>

";


$mail = new PHPMailer;
$mail->From = from@mail.com;
$mail->FromName = name;
$mail->addAddress('to@mail.com', 'test');     
$mail->isHTML(true);                                  

$mail->Subject = 'subject';
$mail->Body    = $body;




?>

Waiting for your support, kindly let me know if you didn't understand my question. 等待您的支持,如果您不明白我的问题,请告诉我。

My form in below 我的表格如下

<form action="https://domain/Fault_Mail.php" method="post" id="Form">
<input type="text" readonly id="FaultNo001" style="background:none; border: 0;" class="Font4" value="Not Availables1" name="FaultNo001" size="100">
<input type="text" readonly id="FaultNo002" style="background:none; border: 0;" class="Font4" value="" name="FaultNo002" size="100">
<input type="submit" value="Submit" class="SubmitButton" border="2" >
</form>

$mail->Body = str_replace('Not available','',$body);

but consider preventing to send this value. 但请考虑阻止发送此值。 If you later decide to change the value in the form (why not numeric) or if you translate to another language, you have to change this line of code as well 如果您以后决定更改表单中的值(为什么不是数字)或转换为另一种语言,则也必须更改此代码行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM