function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function generateInstantEmail($bookId){ include 'dbconn.php'; $sqlpId = "SELECT PROPERTY_CODE, GUEST_EMAIL FROM PROPERTY_DETAILS WHERE Id=1"; $resultpId = $conn->query($sqlpId); if ($resultpId->num_rows > 0) { // output data of each row while($rowpId = $resultpId->fetch_assoc()) { $propertyCode = $rowpId["PROPERTY_CODE"]; $guestEmail = $rowpId["GUEST_EMAIL"]; } } $sql = "SELECT Id, GUEST_NAME, EMAIL_ADDR, PIN_CODE, CHECK_IN_DATE, CHECK_OUT_DATE FROM AIRBNB_BOOKINGS WHERE STATUS='ACTIVE' AND EMAIL_SENT_AT IS NULL AND Id=" . $bookId; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row $row = $result->fetch_assoc(); $guestId = $row["Id"]; $guestName = $row["GUEST_NAME"]; $splitName = explode(" ", $guestName); $guestFirstName = $splitName[0]; $guestLastName = $splitName[1]; $emailAddress = $row["EMAIL_ADDR"]; $pinCode = $row["PIN_CODE"]; $checkInDate = $row["CHECK_IN_DATE"]; $checkOutDate = $row["CHECK_OUT_DATE"]; $recordCount = "send"; } else { echo "No emails to be sent!"; } //email variables $to = $emailAddress; //$to = 'cwill207@gmail.com'; $from = 'unit3415@freedomsailcharters.com'; $from_name = 'Craig & Samantha Williams'; $ccs = 'kellnjgirl3@aol.com'; $bccs = 'samantha30312@gmail.com,cwill207@gmail.com'; $checkInDate = date_format(date_create($checkInDate), "m/d/Y"); $checkOutDate = date_format(date_create($checkOutDate), "m/d/Y"); //attachment files path array $files = array('/home/cwill207/public/slooptravel/airbnb/docs/check-in-3415.pdf','/home/cwill207/public/slooptravel/airbnb/docs/check-out.pdf'); $subject = 'Your Stay in Hilton Head: ' . $checkInDate . " - " . $checkOutDate; $html_content = '
'; $html_content = $guestEmail . ''; $html_content = str_replace("{guestFirstName}", $guestFirstName, $html_content); $html_content = str_replace("{pinCode}", $pinCode, $html_content); $html_content = str_replace("{propertyCode}", $propertyCode, $html_content); $html_content = str_replace("{checkInDate}", $checkInDate, $html_content); $html_content = str_replace("{checkOutDate}", $checkOutDate, $html_content); //==================== if($recordCount == 'send'){ //call multi_attach_mail() function and pass the required arguments $send_email = multi_attach_mail($to, $ccs, $bccs, $subject,$html_content,$from,$from_name,$files); } //print message after email sent if($send_email){ //echo "Mail Sent!