我正在尝试弄清楚如何在BCC中添加电子邮件地址。由于我添加了更多的" $ headers"来添加盲目的电子邮件地址,因此整个代码不再运行。
<?php
// put your email address here
$youremail = 'xxx@xxx.it';
// if the url field is empty
if(isset($_POST['url']) && $_POST['url'] == ''){
// prepare message
$body = "Nuovo messaggio dal sito web :
Nome: $_POST[name]
Azienda: $_POST[company]
Telefono: $_POST[phone]
Email: $_POST[email]
Messaggio: $_POST[message]";
if( $_POST['email'] && !preg_match( "/[rn]/", $_POST['email']) ) {
$headers = "From: $_POST[email]";
} else {
$headers = "From: $youremail";
}
$headers .= "Bcc: yyy@yyy.comrn";
mail($youremail, 'Richiesta Informazioni dal Sito Web', $body, $headers );
}
?>
您也需要在标题的第一行中添加线路休息:
if( $_POST['email'] && !preg_match( "/[rn]/", $_POST['email']) ) {
$headers = "From: $_POST[email]rn";
} else {
$headers = "From: $youremailrn";
}
$headers .= "Bcc: yyy@yyy.comrn";
mail($youremail, 'Richiesta Informazioni dal Sito Web', $body, $headers );
}
看起来您忘记了From
标头上的线结尾。
if( $_POST['email'] && !preg_match( "/[rn]/", $_POST['email']) ) {
$headers = "From: $_POST[email]rn";
} else {
$headers = "From: $youremailrn";
}