我有以下发送电子邮件的代码。
这对于生产环境是否足够好/安全。即它会阻止机器人、使用它发送垃圾邮件的 curl 脚本以及停止电子邮件注入等吗?
<?php
require_once('recaptchalib.php');
$privatekey = "private keys goes here";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again. " .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
require 'class.phpmailer.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Set who the message is to be sent from
$mail->SetFrom('oshirowanen@localhost.com');
//Set who the message is to be sent to
$mail->AddAddress($_POST['email']);
//Set the subject line
$mail->Subject = 'subject goes here';
//Replace the plain text body with one created manually
$mail->Body = $_POST['message'];
//Send the message, check for errors
if(!$mail->Send()) {
die ("Mailer Error: " . $mail->ErrorInfo);
} else {
echo "Message sent!";
}
}
?>
所以基本上,我要问的是,上面的代码对于生产环境是否足够安全、足够安全、足够好?