如何通过examplep运行联系人表单



所以我创建了我的联系人表单,为了测试它,我一直在使用examplep作为本地主机。出于某种原因,无论我做什么,我每次都会收到相同的警告/错误,

'警告:mail((:"sendmail_from";在php.ini或自定义";发件人:";第13行上的C:\examplep\htdocs\COH3\contactMail.php中缺少标头

这是我在PHP中的代码:

<?php
if(isset($_POST['send'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "********@yahoo.com";
$headers= "From: ********@yahoo.com";
if(empty($name) || empty($email) || empty($message)){
echo "All input fields are required";
} else{
if(mail($name, $email, $message, $to, $headers)){
echo "Your message has been sent successfully";
}else{
echo "Message failed to send";
}
}
}
header("Loction: contact.html");
?>

这是php.ini

[mail function]
SMTP=smtp.mail.yahoo.com
smtp_port=465
sendmail_from = ********@yahoo.com
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"

这是sendmail.ini

smtp_server=smtp.mail.yahoo.com
smtp_port=465
error_logfile=error.log
debug_logfile=debug.log
auth_username=********@yahoo.com
auth_password=**********
force_sender=********@yahoo.com

我该怎么做才能让这个东西发挥作用?

mail ( string $to , string $subject , string $message , array|string $additional_headers = [] , string $additional_params = "" ) : bool

add_headers位于位置4。在您的代码中。它位于位置5。我认为这是一个错误。

添加基本标题

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

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

最新更新