У меня сейчас есть сайт Yahoo.Моя форма PHP может отправлять электронные письма как мне, так и копии отправителю.
if( isset($_POST) ){
//form validation vars
$formok = true;
$errors = array();
//$tz=timezone_open("Australia/Brisbane");
//sumbission data
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = gmdate('D d F Y', time()+(36000));
//$date = gmdate(' D d F Y');
//gmdate('D d F Y', time()+(36000));
$time = gmdate(' H:i:s', time()+36000);//form data
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$enquiry = $_POST['enquiry'];
$message = $_POST['message'];
//validate form data
//validate name is not empty
if(empty($name)){
$formok = false;
$errors[] = "You have not entered a name";
}
//validate email address is not empty
if(empty($email)){
$formok = false;
$errors[] = "You have not entered an email address";
//validate email address is valid
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$formok = false;
$errors[] = "You have not entered a valid email address";
}
//validate telephone is not empty
if(empty($telephone)){
$formok = false;
$errors[] = "You have not entered your cellphone number";
}
//validate message is not empty
if(empty($message)){
$formok = false;
$errors[] = "You have not entered a message";
}
//validate message is greater than 20 charcters
elseif(strlen($message) <20){
$formok = false;
$errors[] = "Your message must be greater than 20 characters";
}
//send email if all is ok
if($formok){
// ini_set("sendmail_from","[email protected]");
ini_set("sendmail_from", '$email');$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n\n" .$emailbody = "<pYou has received a new message from the enquiries form.</p
<pThis message was sent by {$name} from the IP Address: {$ipaddress} on {$date} at {$time}</p
<p<strongName: </strong {$name} </p
<p<strongEmail Address: </strong {$email} </p
<p<strongTelephone: </strong {$telephone} </p
<p<strongEnquiry: </strong {$enquiry} </p
<p<strongMessage: </strong {$message} </p";
mail("[email protected]", "New Enquiry from website contact form", $emailbody, $headers);
mail("$email", "{$name} Your Enquiry", $emailbody, $headers);
}//what we need to return back to our form
$returndata = array(
'posted_form_data' = array(
'name' = $name,
'email' = $email,
'telephone' = $telephone,
'enquiry' = $enquiry,
'message' = $message
),
'form_ok' = $formok,
'errors' = $errors
);//if this is not an ajax request
if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest'){
//set session variables
session_start();
$_SESSION['cf_returndata'] = $returndata;
//redirect back to form
header('location: http://www.mywebsite.com/thankyou.html');
//header('location: ' . $_SERVER['HTTP_REFERER']);
}
}
Вся помощь будет оценена
Задача ещё не решена.
Других решений пока нет …