我正在创建一个联系表单,出于某种原因,当我在标题中使用变量时,电子邮件不会被发送。 这个有效:
$first_name = (isset($_POST['firstname']) ? $_POST['firstname'] : null);
$last_name = (isset($_POST['lastname']) ? $_POST['lastname'] : null);
$email = (isset($_POST['email']) ? $_POST['email'] : null);
$message = (isset($_POST['message']) ? $_POST['message'] : null);
$mail_to = "MyEmail";
$subject = "Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: '.$first_name.' '.$last_name.' <info@email.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($mail_to, $subject, $message, $headers)
而且这个没有
$first_name = (isset($_POST['firstname']) ? $_POST['firstname'] : null);
$last_name = (isset($_POST['lastname']) ? $_POST['lastname'] : null);
$email = (isset($_POST['email']) ? $_POST['email'] : null);
$message = (isset($_POST['message']) ? $_POST['message'] : null);
$mail_to = "MyEmail";
$subject = "Subject";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: '.$first_name.' '.$last_name.' <'.$email.'>'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($mail_to, $subject, $message, $headers)
我在谈论这些问题:
$headers .= 'From: '.$first_name.' '.$last_name.' <info@email.com>'."\r\n";
$headers .= 'From: '.$first_name.' '.$last_name.' <'.$email.'>'."\r\n";
这一直有效,直到我将电子邮件变量添加到标题中,有人可以解释我的错误吗?
答案 0 :(得分:0)
尝试将变量放在您的名字&lt;&gt;
中