<?php
header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
if (isset ($_POST['phone'])) {
$subject = "Email from android app";
$subject = "=?utf-8?b?".base64_encode($subject)."?=";
if (($_POST['haveCar']) == 1) { $car = "from app"; } else {$car = "No";}
$message = "site/app: " . $car . "\nPhone: " .$_POST['phone']. "\nCity: " .$_POST['city']."\n";
$boundary = md5(date('r', time()));
// $filesize = '';
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "From: " . $from . "\r\n";
$headers .= "Reply-To: " . $from . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$filename3 = $_POST['fileFF3filename'];
$filetype = "image/jpg";
$filesize = "5000000";
$attachment3 = chunk_split($_POST['fileFF3']) ;
$filename4 = $_POST['fileFF4filename'];
$attachment4 = chunk_split($_POST['fileFF4']) ;
$message="
Content-Type: multipart/mixed; boundary=\"$boundary\"
--$boundary
Content-Type: text/plain; charset=\"utf-8\"
Content-Transfer-Encoding: 7bit
$message";
// for($i=0;$i<count($_FILES['fileFF']['name']);$i++) {
// if(is_uploaded_file($_FILES['fileFF']['tmp_name'][$i])) {
// $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF']['tmp_name'][$i])));
// $filename = $_FILES['fileFF']['name'][$i];
// $filetype = $_FILES['fileFF']['type'][$i];
// $filesize += $_FILES['fileFF']['size'][$i];
$message.="
--$boundary
Content-Type: \"$filetype\"; name=\"$filename4\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$filename4\"
$attachment4";
$message.="
--$boundary
Content-Type: \"$filetype\"; name=\"$filename3\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$filename3\"
$attachment3";
// }
// }
$message.="
--$boundary--";
if ($filesize < 20000000) { // test file size
mail($to, $subject, $message, $headers);
echo $_POST['phone'].', Message sended!';
} else {
echo 'Size >2.';
}
}
?>