我是新來的stackoverflow並找不到答案是我的問題是;如何在php中保護我的mail()代碼以防止人們添加最終會導致羣發郵件的密件抄送?我的網站使用PHP郵件()服務在我的網站中輸入新評論時向我發送電子郵件。防止人們篡改它的最好方法是什麼,例如刪除密件抄送?我至今是:php mail()刪除CC,BCC和安全
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 = '[email protected]';
$subject = 'Website - comment';
$body = 'A new comment has been entered on the website.'."\n\n"."$name".' said: '."\n\n"."$comment";
mail($to,$subject,$body);
如何不重新發明輪子並開始使用phpmailer? PS:你爲變量應用'mysql_real_escape_string'是什麼? – zerkms
該功能默認情況下會詢問服務器魔術引號是打開還是關閉。根據結果,適當的安全措施將被激活,從而防止SQL注入或類似的時候發表評論。 – Medic
除非立即使用結果作爲SQL查詢的一部分,否則不需要(也不應該)使用mysql_real_escape_string。 (而'mail()'不是SQL查詢。) – duskwuff