我需要一个表单来根据用户下拉选择发送给多个不同的收件人。这是我到目前为止所阅读的内容......我可以让它说成功,但我没有收到电子邮件。请帮忙!!
html:
<select id="sendto" class="css-select" name="sendto">
<option id="sales" value="gmail" name="sendto">Gmail</option>
<option id="support" value="yahoo" name="sendto">yahoo</option>
</select>
PHP:
<?php
$i = $_POST["sendto"];
switch ($i) {
case "gmail":
$sendto = "gmail@gmail.com";
break;
case "recpro":
$sendto = "yahoo@yahoo.com";
break;
default:
$sendto = "gmail@gmail.com"; //opional
break;
}
function sanitize( $s ){
$injections = array('/(\n+)/i',
'/(\r+)/i',
'/(\t+)/i',
'/(%0A+)/i',
'/(%0D+)/i',
'/(%08+)/i',
'/(%09+)/i'
);
$s = preg_replace( $injections, '', $s );
return $s;
}
//catch the posted data
$first_name = sanitize( $_POST['first_name'] );
$last_name = sanitize( $_POST['last_name'] );
$email = sanitize( $_POST['email'] );
$telephone = sanitize( $_POST['telelphone'] );
$body = $telephone."\n\n";
$body.= $first_name."<$email>";
$headers = "From: $last_name<$email>";
if(mail($send_to, $subject, $body, $headers)):
echo "success";
else:
echo "error";
endif;
?>
我需要它是标头注入安全的。