이 스크립트는 온라인 상태이며 작동하는 것으로 보입니다. 그러나 양식이 name, phone1, phone2를 처리하지 않는 것 같습니다.문의 양식 : 전화 번호를 보낼 수 없습니다
name, phone1, phone2가 처리되고 처리되는 방법이 표시되지 않습니다.
메일, 전화 1 및 전화 2의 이름을 얻는 데 도움을 줄 수 있습니까?
양식 코드에 올바른 입력란이 있고 Chrome console
은 데이터가 전송되었음을 나타냅니다. 실종 된 게 뭐라고 생각하니?
$recipient_email = "[email protected]"; //recepient
$from_email = "[email protected]"; //from email using site domain.
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
die('Sorry Request must be Ajax POST'); //exit script
}
if($_POST){
$sender_name = filter_var($_POST["name"], FILTER_SANITIZE_STRING); //capture sender name
$sender_email = filter_var($_POST["email"], FILTER_SANITIZE_STRING); //capture sender email
$country_code = filter_var($_POST["phone1"], FILTER_SANITIZE_NUMBER_INT);
$phone_number = filter_var($_POST["phone2"], FILTER_SANITIZE_NUMBER_INT);
$subject = filter_var($_POST["subject"], FILTER_SANITIZE_STRING);
$message = filter_var($_POST["message"], FILTER_SANITIZE_STRING); //capture message
$attachments = $_FILES['file_attach'];
//php validation
if(strlen($sender_name)<4){ // If length is less than 4 it will output JSON error.
print json_encode(array('type'=>'error', 'text' => 'Name is too short or empty!'));
exit;
}
if(!filter_var($sender_email, FILTER_VALIDATE_EMAIL)){ //email validation
print json_encode(array('type'=>'error', 'text' => 'Please enter a valid email!'));
exit;
}
if(!filter_var($country_code, FILTER_VALIDATE_INT)){ //check for valid numbers in country code field
$output = json_encode(array('type'=>'error', 'text' => 'Enter only digits in country code'));
exit;
}
if(!filter_var($phone_number, FILTER_SANITIZE_NUMBER_FLOAT)){ //check for valid numbers in phone number field
print json_encode(array('type'=>'error', 'text' => 'Enter only digits in phone number'));
exit;
}
if(strlen($subject)<3){ //check emtpy subject
print json_encode(array('type'=>'error', 'text' => 'Subject is required'));
exit;
}
if(strlen($message)<3){ //check emtpy message
print json_encode(array('type'=>'error', 'text' => 'Too short message! Please enter something.'));
exit;
}
$file_count = count($attachments['name']); //count total files attached
$boundary = md5("sanwebe.com");
if($file_count > 0){ //if attachment exists
//header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:".$from_email."\r\n";
$headers .= "Reply-To: ".$sender_email."" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
//message text
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= chunk_split(base64_encode($message));
//attachments
for ($x = 0; $x < $file_count; $x++){
if(!empty($attachments['name'][$x])){
if($attachments['error'][$x]>0) //exit script and output error if we encounter any
{
$mymsg = array(
1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
3=>"The uploaded file was only partially uploaded",
4=>"No file was uploaded",
6=>"Missing a temporary folder");
print json_encode(array('type'=>'error',$mymsg[$attachments['error'][$x]]));
exit;
}
//get file info
$file_name = $attachments['name'][$x];
$file_size = $attachments['size'][$x];
$file_type = $attachments['type'][$x];
//read file
$handle = fopen($attachments['tmp_name'][$x], "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content)); //split into smaller chunks (RFC 2045)
$body .= "--$boundary\r\n";
$body .="Content-Type: $file_type; name=".$file_name."\r\n";
$body .="Content-Disposition: attachment; filename=".$file_name."\r\n";
$body .="Content-Transfer-Encoding: base64\r\n";
$body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n";
$body .= $encoded_content;
}
}
}else{ //send plain email otherwise
$headers = "From:".$from_email."\r\n".
"Reply-To: ".$sender_email. "\n" .
"X-Mailer: PHP/" . phpversion();
$body = $message;
}
$sentMail = mail($recipient_email, $subject, $body, $headers);
if($sentMail) //output success or failure messages
{
print json_encode(array('type'=>'done', 'text' => 'Thank you for your email'));
exit;
}else{
print json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
exit;
}
}
PS :이 오픈 소스 스크립트가 응답하지 않는 썼다 개발자
다음은 PHP 스크립트입니다.
당신의 천국 '을 도움이되기를 바랍니다 ... 바로 이메일 전송 라인 전에 $ 바디 변수에
그들을 연결할 수 있습니다 $ body –
에 전화 번호를 추가하여 메시지 또는 제목에 전화 번호를 넣으시겠습니까? –