我正在为我的网站制作联系表单,我正在努力让用户通过HTML表单提交他们的电子邮件和姓名。我的表单有一个reCaptcha,这里是action
文件:
<?php
if(isset($_POST['submit']) && !empty($_POST['submit'])):
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
// Your site secret key
$secret = 'my_secret_key';
// Remote user address
$ip = $_SERVER["REMOTE_ADDR"];
// Get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $secret . '&response=' . $_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
if($responseData->success):
// Contact form submission code
$email = htmlentities(!empty($_POST['email'])?$_POST['email']:'');
$to = 'myemail@gmail.com';
$subject = 'A new email from ' . $email;
$htmlContent = '<p><a href="mailto:' . $email . '">' . $email . '</a></p>';
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: User <' . $email . '>' . "\r\n";
// Send email
@mail($to, $subject, $htmlContent, $headers);
@mail($email, $subject, $htmlContent, $headers);
endif;
endif;
endif;
?>
因此,如果用户在其电子邮件字段中提交@(at),则电子邮件永远不会被发送。我怀疑这可能是因为上面的代码。 mail
可以发送/接受哪些字符有任何限制吗?如果是这样,为什么?我尝试发送这样的消息:
адгтф〜`#$%^&安培; *()_- + =&LT;,&GT; /?:;“'\ | {} []
它从来没有到我的电子邮箱。非常感谢帮助!