dongyun65343
2012-09-07 21:32
浏览 96
已采纳

php mail()删除CC,BCC和安全性

I'm new to stackoverflow and couldn't find an answer to my question which is; How do I secure my mail() code in php to prevent people from adding bcc which would ultimatly result in mass mailing? My website uses the PHP mail() service to email me when a new comment has been entered in my site. What is the best way to prevent people tampering with it, such as removing the bcc? What I have so far is:

function mres($input){
if (get_magic_quotes_gpc()){
    $input = stripslashes($input);
}
return mysql_real_escape_string($input);
}
$name = strip_tags(mres($_POST['name']));
$comment = strip_tags(mres($_POST['comment']));

$to = 'myself@gmail.com';
$subject = 'Website - comment';
$body = 'A new comment has been entered on the website.'."

"."$name".' said:         '."

"."$comment";
mail($to,$subject,$body);

图片转代码服务由CSDN问答提供 功能建议

我是stackoverflow的新手,无法找到我的问题的答案。 如何在php中保护我的mail()代码以防止人们添加最终会导致群发邮件的密件抄送? 我的网站使用PHP mail()服务在我的网站上输入新评论时给我发电子邮件。 防止人们篡改它的最佳方法是什么,例如删除密送? 到目前为止我所拥有的是:

  function mres($ input){
if(get_magic_quotes_gpc()){
 $ input = stripslashes($ input); 
}  
return mysql_real_escape_string($ input); 
} 
 $ name = strip_tags(mres($ _ POST ['name'])); 
 $ comment = strip_tags(mres($ _ POST ['comment'])); \  n 
 $ to ='myself@gmail.com'; 
 $ subject ='网站 - 评论'; 
 $ body ='已在网站上输入新评论。'。“
 
”。  “$名”。” 说:'。“
 
”。“$ comment”; 
mail($ to,$ subject,$ body); 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题