function send_file($name) { OB_END_CLEAN(); $path = $name; //"../temp/".$name; if (!IS_FILE($path) or CONNECTION_STATUS() != 0) { return FALSE; } HEADER("Cache-Control: no-store, no-cache, must-revalidate"); HEADER("Cache-Control: post-check=0, pre-check=0", FALSE); HEADER("Pragma: no-cache"); HEADER("Expires: " . GMDATE("D, d M Y H:i:s", MKTIME(DATE("H") + 2, DATE("i"), DATE("s"), DATE("m"), DATE("d"), DATE("Y"))) . " GMT"); HEADER("Last-Modified: " . GMDATE("D, d M Y H:i:s") . " GMT"); HEADER("Content-Type: application/octet-stream"); HEADER("Content-Length: " . (string) FILESIZE($path)); HEADER("Content-Disposition: inline; filename={$name}"); HEADER("Content-Transfer-Encoding: binary\n"); if ($file = FOPEN($path, 'rb')) { while (!FEOF($file) and CONNECTION_STATUS() == 0) { print FREAD($file, 1024 * 8); FLUSH(); } FCLOSE($file); } return CONNECTION_STATUS() == 0 and !CONNECTION_ABORTED(); }
public static function _sendCalendarEmailOld1($options) { // Pear Mail Library require_once "Mail.php"; $email_model = new Default_Model_EmailLogs(); $date = new Zend_Date(); if (is_array($options['toEmail'])) { $toemailData = implode(',', $options['toEmail']); } else { $toemailData = $options['toEmail']; } $meeting_duration = 3600; // 1hours $ISTTimeDifferenceInMS = 16200; $from_address = !empty($options['fromEmail']) ? $options['fromEmail'] : SUPERADMIN_EMAIL; $from_name = !empty($options['fromName']) ? $options['fromName'] : DONOTREPLYNAME; $to_name = isset($options['toName']) ? $options['toName'] : NULL; $to_address = $toemailData; $startTime = !empty($options['starttime']) ? $options['starttime'] : "01/01/2015 13:00:00"; /* Meeting Stamp = Interview Date + Time */ $startdatetime = sprintf("%s %s", $options['interviewdate'], $options['starttime']); $meetingstamp = STRTOTIME($startdatetime . " UTC"); //$endTime = (!empty($options['endtime'])) ? $options['endtime'] : "01/01/2015 14:00:00"; //$meetingstamp = STRTOTIME($startTime . " UTC"); $dtstart = GMDATE("Ymd\\THis\\Z", $meetingstamp - $ISTTimeDifferenceInMS); $dtend = GMDATE("Ymd\\THis\\Z", $meetingstamp - ($ISTTimeDifferenceInMS + $meeting_duration)); $subject = $options['subject']; $description = str_replace("\r\n", "\\n", $options['message']); $location = !empty($options['location']) ? $options['location'] : "Delta HR Office"; $domain = 'deltaintech.com'; $cal_unique_id = isset($options['calUniqueID']) ? $options['calUniqueID'] : date("Ymd\\TGis", strtotime($startTime)) . rand() . "@" . $domain; $cal_method = isset($options['method']) ? $options['method'] : 'REQUEST'; $mime_boundary = "----Meeting Booking----" . MD5(TIME()); $headers = array("From" => $from_name . " <" . $from_address . ">", "Reply-To" => $from_name . " <" . $from_address . ">", "MIME-Version" => "1.0", "Content-Type" => "multipart/alternative; boundary=\"{$mime_boundary}\"", "Content-class" => "urn:content-classes:calendarmessage"); //Create Email Body (HTML) $message = "--{$mime_boundary}\r\n"; $message .= "Content-Type: text/html; charset=UTF-8\n"; $message .= "Content-Transfer-Encoding: 8bit\n\n"; $message .= "<html>\n"; $message .= "<body>\n"; $message .= '<p>Dear ' . $to_name . ',</p>'; $message .= '<p>' . $description . '</p>'; $message .= "</body>\n"; $message .= "</html>\n"; $message .= "--{$mime_boundary}\r\n"; $ical = 'BEGIN:VCALENDAR' . "\r\n" . 'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" . 'VERSION:2.0' . "\r\n" . 'METHOD:' . $cal_method . "\r\n" . 'BEGIN:VTIMEZONE' . "\r\n" . 'TZID:(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi' . "\r\n" . 'BEGIN:STANDARD' . "\r\n" . 'DTSTART:20091101T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" . 'TZOFFSETFROM:-0400' . "\r\n" . 'TZOFFSETTO:-0500' . "\r\n" . 'TZNAME:EST' . "\r\n" . 'END:STANDARD' . "\r\n" . 'BEGIN:DAYLIGHT' . "\r\n" . 'DTSTART:20090301T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" . 'TZOFFSETFROM:-0500' . "\r\n" . 'TZOFFSETTO:-0400' . "\r\n" . 'TZNAME:EDST' . "\r\n" . 'END:DAYLIGHT' . "\r\n" . 'END:VTIMEZONE' . "\r\n" . 'BEGIN:VEVENT' . "\r\n" . 'ORGANIZER;CN="' . $from_name . '":MAILTO:' . $from_address . "\r\n" . 'ATTENDEE;CN="' . $to_name . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $to_address . "\r\n" . 'LAST-MODIFIED:' . date("Ymd\\TGis") . "\r\n" . 'UID:' . $cal_unique_id . "\r\n" . 'DTSTAMP:' . date("Ymd\\TGis") . "\r\n" . 'DTSTART:' . $dtstart . "\r\n" . 'DTEND:' . $dtend . "\r\n" . 'TRANSP:OPAQUE' . "\r\n" . 'SEQUENCE:1' . "\r\n" . 'SUMMARY:' . $subject . "\r\n" . 'LOCATION:' . $location . "\r\n" . 'CLASS:PUBLIC' . "\r\n" . 'PRIORITY:5' . "\r\n" . 'BEGIN:VALARM' . "\r\n" . 'TRIGGER:-PT15M' . "\r\n" . 'ACTION:DISPLAY' . "\r\n" . 'DESCRIPTION:Reminder' . "\r\n" . 'END:VALARM' . "\r\n" . 'END:VEVENT' . "\r\n" . 'END:VCALENDAR' . "\r\n"; $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST\\n'; $message .= "Content-Transfer-Encoding: 8bit\n\n"; $message .= $ical; //$options['ical'] = (!empty($options['ical'])) ? $options['ical'] : $ical; $options['message'] = $message; $data = array('toEmail' => $toemailData, 'toName' => isset($options['toName']) ? $options['toName'] : NULL, 'emailsubject' => $options['subject'], 'header' => $options['header'], 'message' => $message, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss')); /* if (isset($options['cc'])) $data['cc'] = $options['cc']; if (isset($options['bcc'])) $data['bcc'] = $options['bcc']; */ $id = $email_model->SaveorUpdateEmailData($data, ''); if (!isset($options['cron'])) { //$mail_status = sapp_Mail::_emailascalendar($options); $smtp = Mail::factory('smtp', array('host' => MAIL_TLS . '://' . MAIL_SMTP, 'port' => MAIL_PORT, 'auth' => true, 'username' => MAIL_USERNAME, 'password' => MAIL_PASSWORD)); $mail_status = $smtp->send($to_address, $headers, $message); $where = array('id=?' => $id); $newdata['modifieddate'] = $date->get('yyyy-MM-dd HH:mm:ss'); $newdata['is_sent'] = 1; if ($mail_status) { $id = $email_model->SaveorUpdateEmailData($newdata, $where); return $id; } else { return "fail"; } } }