php - 表单邮件安全
问题描述
我有一个基于 php 的表单邮件程序。我已经使用了很长时间了。但是,我想知道是否有可能使它更安全。有人在以下代码中看到漏洞吗?有没有什么可能的黑客可以注入一些东西的地方?我能想到的其他可能的漏洞是被认为是不安全的已弃用代码,因此通常会被其他东西取代。
<?php
$straddressee = 'info@myexample.com';
$strFrom = '"mailer" <dictformmail@myexample.com>';
$strSubject = 'Message';
$strReturnhtml = 'thankyou.php';
$strDelimiter = ":\t";
if($_POST)
{
$strMailtext = "";
while(list($strName,$value) = each($_POST))
{
if(is_array($value))
{
foreach($value as $value_array)
{
$strMailtext .= $strName.$strDelimiter.$value_array."\n";
}
}
else
{
$strMailtext .= $strName.$strDelimiter.$value."\n";
}
}
if(get_magic_quotes_gpc())
{
$strMailtext = stripslashes($strMailtext);
}
mail($straddressee, $strSubject, $strMailtext, "From: ".$strFrom)
or die("The email could not be sent.");
header("Location: $strReturnhtml");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<body>
<p>Your message:</p>
<form action="<?php echo htmlentities("/mailer/"); ?>" method="post">
<p>Salutation:<input type="text" name="Salutation" /></p>
<p>Your Name:<input type="text" name="name" /></p>
<p>Your Email:<input type="text" name="email" size="30"></p>
<p>Subject:<input type="text" name="subject" size="35"></p>
<p>Your message:<textarea name="Message">message</textarea></p>
<input type="submit" value="submit" />
</form>
</body>
</html>
解决方案
推荐阅读
- react-native - 当抽屉屏幕聚焦于 React-Native 时运行一些代码
- timestamp - Azure 数据工厂、复制数据、Teradata ODBC、日期时间时间戳映射
- reactjs - React Native:如何显示特定类别的帖子?
- python - 如何通过 BeautifulSoup 打印波斯语页面的文本?
- flutter - Flutter:当前 Flutter SDK 版本为 0.0.0-未知
- google-colaboratory - /bin/bash: ./darknet: No such file or directory 问题
- java - 为什么在迭代 HashMap 时在 IF 块中添加元素会起作用?
- arrays - 如何检查数组中元素的位置?
- apache-kafka - KTable-KTable 外键连接语义
- ansible - Ansible 用户模块:如何将 UID 定义为默认设置?