<? mailTo('*****@*****.**','*****@*****.**','ini adalah pesan <h1>test</h1>'); function mailTo ($from, $to, $oggetto, $pesan, $type = "both", $reply = true) { // Standar Header $crlf = chr(10) . chr(13); $intestazione = "To: {$to}" . $crlf; $intestazione .= "From: {$from}" . $crlf; $intestazione .= "Return-Path: " . (($reply)? $from : substr_replace($from, "noreply", 0, strpos($from, '@'))) . $crlf; $intestazione .= 'Reply-To: ' .(($reply)? $from : substr_replace($from, "noreply", 0, strpos($from, '@'))) . $crlf; $intestazione .= 'X-Mailer: PHP/' . phpversion() . $crlf; // MIME boundary $separatore = 'PHP' . md5(uniqid(time())); // MIME Header $intestazione .= 'MIME-Version: 1.0' . $crlf; switch ($type){ case 'html' : // Header for client non MIME compatible $intestazione .= 'Content-Type: text/html; charset=ISO-8859-15' . $crlf; $intestazione .= 'Content-Transfer-Encoding: 7bit' . $crlf; $messaggio .= "\n{$pesan}\n"; break; case 'both' : $intestazione .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $separatore . '"' . $crlf; // Create message for no mime client $messaggio .= "For English People: This is a multi-part message in MIME format.\nIf you are reading this, consider upgrading your e-mail client to a MIME-compatible client.\n"; $messaggio .= "For Italian People: Questo è un messaggio MIME.\nSe si stà leggendo questa nota, consigliamo l\'aggiornamento del programma di posta elettronica con uno compatibile MIME";
function sendPartsEmail() { $task = $_GET["task"]; $id = $_GET["ID"]; $rows1 = selectrec("part_no,qty", "failure_details", "failure_id=" . $id); $str1 = ""; $rowCount = 0; foreach ($rows1 as $row1) { if ($row1[1] > 0) { $str1 .= "<tr><td>" . singlefield("part_code", "parts", "part_id=" . $row1[0]) . "</td><td>" . singlefield("part_desc", "parts", "part_id=" . $row1[0]) . "</td><td>" . $row1[1] . "</td></tr>"; $rowCount++; } } if ($task == "failure" && $rowCount > 0) { $table = "failure_details"; $subject = "Parts required for Failure #" . $id; $toEmail = "ashakiran@gladminds.co,naveen.shankar@gladminds.co"; $ccEmail = "*****@*****.**"; $str = '<p>Dear Bajaj Supply team member,</p><br/><p>Please note new request for parts. </p><table style="border-collapse:collapse;width:100%;" width="100%" border="1"> <thead><tr><th style="text-align: center;">' . ucwords($task) . ' #<br /></th> <th style="text-align: center;">' . ucwords($task) . ' Date<br /></th> <th style="text-align: center;">VIN#</th> <th style="text-align: center;">M/s Dealer Name</th> <th style="text-align: center;">Town</th> </tr></thead><tbody>'; $fields = "failure_no, date_time, frame_vin_no, dealer_code, location_id"; $table = "failure"; $cond = "failure_no=" . $id; $rows = singlerec($fields, $table, $cond); $arr = mysql_fetch_row($rows); $str .= '<tr> <td style="text-align: center;">' . $arr[0] . '</td> <td style="text-align: center;">' . $arr[1] . '</td> <td style="text-align: center;">' . $arr[2] . '</td> <td style="text-align: center;">' . singlefield("dealer_name", "dealer", "dealer_code=" . $arr[3]) . '</td> <td style="text-align: center;">' . singlefield("location_name", "locations", "location_id=" . $arr[4]) . '</td> </tr> <tr> <td colspan="5" style="padding:10px;"> <table width="100%"> <tr> <th style="text-align: center;">Parts Requested</th><th style="text-align: center;">Description</th><th width="10%" style="text-align: center;">Qty</th> </tr>'; $str .= $str1 . '</table></td></tr></tbody></table>'; $str .= '<br/><p>Thanks and Regards,</p><div><span style="font-style: italic; font-weight: bold;">GladMinds, FMS team</span></div><p> </p>'; if (mailTo($subject, $toEmail, $str, $ccEmail)) { $arr = array('status' => "1", 'message' => 'Success'); } else { $arr = array('status' => "0", 'message' => 'Failure. Please try again later.'); } echo json_encode($arr); } else { $arr = array('status' => "1", 'message' => 'Email Not Sent'); echo json_encode($arr); } }