Php 如何将从电子邮件更改为表单中的电子邮件
我有下面的表格,我一直在绞尽脑汁想如何将电子邮件地址改成不同的地址 目前,它使用的是php服务器,正在使用的电子邮件上的自动回复正在发送一个自动回复,它只是在制造一个大混乱。任何帮助都将不胜感激Php 如何将从电子邮件更改为表单中的电子邮件,php,email,web,Php,Email,Web,我有下面的表格,我一直在绞尽脑汁想如何将电子邮件地址改成不同的地址 目前,它使用的是php服务器,正在使用的电子邮件上的自动回复正在发送一个自动回复,它只是在制造一个大混乱。任何帮助都将不胜感激 <?php if(isset($_POST['submit'])) { //create an empty errors array $errors = array(); //our form has been submitted if($_POS
<?php
if(isset($_POST['submit'])) {
//create an empty errors array
$errors = array();
//our form has been submitted
if($_POST['name'] == "") {
//the name field is empty
$errors[] = "The name field is empty";
}
if($_POST['email'] == "") {
//the email field is empty
$errors[] = "The email field is empty";
}
if($_POST['comment'] == "") {
//the comment field is empty
$errors[] = "The comment field is empty";
}
if($_POST['phone'] == "") {
//the comment field is empty
$errors[] = "The phone field is empty";
}
if($_POST['passengers'] == "") {
//the comment field is empty
$errors[] = "The passengers field is empty";
}
if($_POST['destination'] == "") {
//the comment field is empty
$errors[] = "The destination field is empty";
}
if(!stripos($_POST['email'], '@')) {
$errors[] = "The email address was not valid";
}
if(count($errors) == 0) {
$sendto = "inquiry@maximtours.net";
$title = "Contact Form";
$email = $_POST['email'];
$message = "Name: ".$_POST['name']. "\n".
"Mail: ".$_POST['email']. "\n".
"Date of Travel: ".$_POST['month'].". " .$_POST['day'].", " .$_POST['year'] ."\n".
"Phone No: ".$_POST['phone']. "\n".
"Number of Passengers: ".$_POST['passengers']. "\n".
"Traveling From: ".$_POST['city']. "\n".
"Destination: ".$_POST['destination']. "\n".
"Comment: ".$_POST['comment']. "\n";
$headers = "From: " . $_POST['email'] . "\r\n" .
"Reply-To: " . $_POST['email'] . "\r\n" .
"X-Mailer: PHP/" . phpversion();
if(mail($sendto, $title, $message, $email, 'inquiry@maximtours.net'.$email)) {
$success = true;
} else {
$success = false;
}
}
}
?>
<?php
if(isset($_POST['submit'])) {
if($success == true && count($errors) == 0) {
echo "<h2>Thanks for getting in touch!</h2>";
}
if(count($errors) == 0 && $success == false && isset($_POST['submit'])) {
echo '<h2>There was a problem with our form. Please email us directly via inquiry@maximtours.net.</h2>';
}
if(isset($_POST['submit']) && $success == false && count($errors) > 0) {
echo "<ul>";
foreach($errors as $e) {
echo "<li>$e</li>";
}
echo "</ul>";
}
}
?>
将mail()函数中的第5个参数更改为希望作为发件人:电子邮件地址的电子邮件地址
mail('to@blah.com','subject!','body!','From: from@blah.com','-f from@blah.com');
我想你需要换些零钱
mail($sendto, $title, $message, $email, 'inquiry@maximtours.net'.$email)
将此更改为
mail($sendto, $title, $message, $headers);
您可以在$headers中设置所需的任何发件人地址。您想更改发件人地址的哪些内容?信封发送者(在
邮件()
呼叫中)或邮件中的发件人:
标题中有问题吗?请解释你期望(或希望看到)什么以及你正在看到什么。