Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mail()中存在四个以上变量的问题-PHP_Php_Email_Variables_Limit - Fatal编程技术网

mail()中存在四个以上变量的问题-PHP

mail()中存在四个以上变量的问题-PHP,php,email,variables,limit,Php,Email,Variables,Limit,我正在尝试构建一个表单,将副本提交给表单所有者和用户。然而 当我尝试在mail()中插入第五个变量时,似乎最后一个变量停止工作: if( empty($errors)) { $to = $email_address; //user email $email_subject = "Some text"; $email_body = "more text"; $from = "From: $myemail \n"; //form owner email $h

我正在尝试构建一个表单,将副本提交给表单所有者和用户。然而 当我尝试在mail()中插入第五个变量时,似乎最后一个变量停止工作:

if( empty($errors))
{
    $to = $email_address; //user email
    $email_subject = "Some text";
    $email_body = "more text"; 
    $from = "From: $myemail \n"; //form owner email
    $headers = "Bcc:" . $myemail;

    mail($to,$email_subject,$email_body,$from,$headers);

    header("Location: $where");
}
漏掉$from我会收到一份发送给用户和表单所有者的邮件副本,但是无法控制电子邮件的“发件人”字段-漏掉$header表单所有者不会收到副本。如果可能的话,我两者都喜欢

我为我的问题的简单性提前表示歉意——我所知道的关于php(以及一般的web开发)的一切都是在这样的论坛上从聪明的家伙那里学到的


这些是邮件的正确参数:

bool-mail(string$to,string$subject,string$message[,string$additional\u headers[,string$additional\u parameters]])

如您所见,第四个参数不是“from”,而是一个headers字符串

请尝试以下示例:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

以下是邮件的正确参数:

bool-mail(string$to,string$subject,string$message[,string$additional\u headers[,string$additional\u parameters]])

如您所见,第四个参数不是“from”,而是一个headers字符串

请尝试以下示例:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

您不能像这样使用from,请参阅您不能像这样使用from,请参阅