@($contact_phone = stripslashes($_REQUEST['contact_phone'])); @($contact_refer = stripslashes($_REQUEST['contact_refer'])); @($q1 = stripslashes($_REQUEST['q1'])); @($q2 = stripslashes($_REQUEST['q2'])); @($q3 = stripslashes($_REQUEST['q3'])); @($q4 = stripslashes($_REQUEST['q4'])); @($q5_support = stripslashes($_REQUEST['q5_support'])); @($q5_opensource = stripslashes($_REQUEST['q5_opensource'])); @($q5_price = stripslashes($_REQUEST['q5_price'])); @($q5_updates = stripslashes($_REQUEST['q5_updates'])); @($q5_developers = stripslashes($_REQUEST['q5_developers'])); @($q5_community = stripslashes($_REQUEST['q5_community'])); @($comments = stripslashes($_REQUEST['comments'])); if (isset($_REQUEST['form_submit'])) { $msg = sprintf("Contact Name: %s\r\n" . "Organization: %s\r\n" . "Referred by: %s\r\n" . "Phone: %s\r\n" . "\r\n" . "#1: Briefly, what does your organization do?\r\n%s\r\n\r\n" . "#2: How is your team currently handling community feedback?\r\n%s\r\n\r\n" . "#3: Are you considering both free and commercial solutions?\r\n%s\r\n\r\n" . "#4: What will be your first important milestone?\r\n%s\r\n\r\n" . "#5: How important are the following benefits in making your decision?\r\n" . "Near-Instant Support: %d\r\nAvailable Source Code: %d\r\nCompetitive Purchase Price: %d\r\n" . "Frequent Product Updates: %d\r\nAccess to Developers: %d\r\nLarge User Community: %d\r\n" . "\r\n" . "Additional Comments: \r\n%s\r\n\r\n", $contact_name, $contact_company, $contact_refer, $contact_phone, $q1, $q2, $q3, $q4, $q5_support, $q5_opensource, $q5_price, $q5_updates, $q5_developers, $q5_community, $comments); FegMail::quickSend('*****@*****.**', "About: {$contact_name} of {$contact_company}", $msg, $contact_email, $contact_name); } } $tpl->assign('step', STEP_FINISHED); $tpl->display('steps/redirect.tpl'); exit; } $tpl->assign('template', 'steps/step_register.tpl'); break; case STEP_UPGRADE: $tpl->assign('template', 'steps/step_upgrade.tpl'); break; // [TODO] Delete the /install/ directory (security) // [TODO] Delete the /install/ directory (security) case STEP_FINISHED: // Set up the default cron jobs
function doRecoverStep1Action() { $translate = DevblocksPlatform::getTranslationService(); @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string')); $worker = null; $results = DAO_Worker::getWhere(sprintf("%s = %s", DAO_Worker::EMAIL, Feg_ORMHelper::qstr($email))); if (!empty($results)) { $worker = array_shift($results); } if (empty($email) || empty($worker)) { return; } $_SESSION[self::KEY_FORGOT_EMAIL] = $email; try { $code = FegApplication::generatePassword(10); $_SESSION[self::KEY_FORGOT_SENTCODE] = $code; $to = $email; $subject = $translate->_('login.forgot.mail.subject'); $body = vsprintf($translate->_('login.forgot.mail.body'), $code); FegMail::quickSend($to, $subject, $body); } catch (Exception $e) { DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step1', 'failed'))); } DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step2'))); }
static function sendMailProperties($properties) { $status = true; @($toStr = $properties['to']); @($cc = $properties['cc']); @($bcc = $properties['bcc']); @($subject = $properties['subject']); @($content = $properties['content']); @($files = $properties['files']); $mail_settings = self::getMailerDefaults(); if (empty($properties['from_addy'])) { @($from_addy = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_FROM, $_SERVER['SERVER_ADMIN'])); } if (empty($properties['from_personal'])) { @($from_personal = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_PERSONAL, '')); } if (empty($subject)) { $subject = '(no subject)'; } // [JAS]: Replace any semi-colons with commas (people like using either) $toList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $toStr)); $mail_headers = array(); $mail_headers['X-FegCompose'] = '1'; // Headers needed for the ticket message $log_headers = new Swift_Message_Headers(); $log_headers->setCharset(LANG_CHARSET_CODE); $log_headers->set('To', $toList); $log_headers->set('From', !empty($from_personal) ? sprintf("%s <%s>", $from_personal, $from_addy) : sprintf('%s', $from_addy)); $log_headers->set('Subject', $subject); $log_headers->set('Date', date('r')); foreach ($log_headers->getList() as $hdr => $v) { if (null != ($hdr_val = $log_headers->getEncoded($hdr))) { if (!empty($hdr_val)) { $mail_headers[$hdr] = $hdr_val; } } } try { $mail_service = DevblocksPlatform::getMailService(); $mailer = $mail_service->getMailer(FegMail::getMailerDefaults()); $email = $mail_service->createMessage(); $email->setTo($toList); // cc $ccs = array(); if (!empty($cc) && null != ($ccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $cc)))) { $email->setCc($ccList); } // bcc if (!empty($bcc) && null != ($bccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $bcc)))) { $email->setBcc($bccList); } $email->setFrom(array($from => $personal)); $email->setSubject($subject); $email->generateId(); $headers = $email->getHeaders(); $headers->addTextHeader('X-Mailer', 'Fax Email Gateway (FEG) ' . APP_VERSION . ' (Build ' . APP_BUILD . ')'); $email->setBody($content); // Mime Attachments if (is_array($files) && !empty($files)) { foreach ($files['tmp_name'] as $idx => $file) { if (empty($file) || empty($files['name'][$idx])) { continue; } $email->attach(Swift_Attachment::fromPath($file)->setFilename($files['name'][$idx])); } } // Headers foreach ($email->getHeaders()->getAll() as $hdr) { if (null != ($hdr_val = $hdr->getFieldBody())) { if (!empty($hdr_val)) { $mail_headers[$hdr->getFieldName()] = $hdr_val; } } } // [TODO] Allow separated addresses (parseRfcAddress) // $mailer->log->enable(); if (!@$mailer->send($email)) { throw new Exception('Mail failed to send: unknown reason'); } // $mailer->log->dump(); } catch (Exception $e) { // Do Something $status = false; } // Give plugins a chance to note a message is imported. $eventMgr = DevblocksPlatform::getEventService(); $eventMgr->trigger(new Model_DevblocksEvent('email.send', array('properties' => $properties, 'send_status' => $status ? 2 : 1))); return $status; }
function ExportEmail(Model_ExportType $export_type) { $logger = DevblocksPlatform::getConsoleLog(); $db = DevblocksPlatform::getDatabaseService(); @($email_current_hour = 0); @($email_sent_today = 0); $memory_limit = ini_get('memory_limit'); if (substr($memory_limit, 0, -1) < 128) { @ini_set('memory_limit', '128M'); } @set_time_limit(0); // Unlimited (if possible) $logger->info("[Email Exporter] Overloaded memory_limit to: " . ini_get('memory_limit')); $logger->info("[Email Exporter] Overloaded max_execution_time to: " . ini_get('max_execution_time')); $sql = sprintf("SELECT mr.id " . "FROM message_recipient mr " . "inner join customer_recipient cr on mr.recipient_id = cr.id " . "WHERE mr.send_status in (0,3,4) " . "AND cr.is_disabled = 0 " . "AND cr.export_type = %d " . "AND cr.type = 0 ", $export_type->id); $rs = $db->Execute($sql); // Loop though pending outbound emails. while ($row = mysql_fetch_assoc($rs)) { $id = $row['id']; $logger->info("[Email Exporter] Procing MR ID: " . $id); $message_recipient = DAO_MessageRecipient::get($id); $message = DAO_Message::get($message_recipient->message_id); $message_lines = explode('\\n', substr($message->message, 1, -1)); $recipient = DAO_CustomerRecipient::get($message_recipient->recipient_id); $to = !empty($recipient->address_to) ? array($recipient->address => $recipient->address_to) : array($recipient->address); $subject = $recipient->subject; $from_addy = !empty($export_type->params['7']) ? $export_type->params['7'] : null; $from_personal = !empty($export_type->params['11']) ? $export_type->params['11'] : null; //echo "<pre>"; //print_r($export_type); //echo "</pre>"; // FIXME - Need to add in filter for now everything is unfiltered. $send_status = FegMail::sendMail($to, $subject, implode("\r\n", $message_lines), $from_addy, $from_personal); $logger->info("[Email Exporter] Send Status: " . ($send_status ? "Successful" : "Failure")); // Give plugins a chance to run export $eventMgr = DevblocksPlatform::getEventService(); $eventMgr->trigger(new Model_DevblocksEvent('cron.send.email', array('recipient' => $recipient, 'message' => $message, 'message_lines' => $message_lines, 'message_recipient' => $message_recipient, 'send_status' => $send_status))); if ($send_status) { $email_current_hour++; $email_sent_today++; } $fields = array(DAO_MessageRecipient::SEND_STATUS => $send_status ? 2 : 1, DAO_MessageRecipient::CLOSED_DATE => $send_status ? time() : 0); DAO_MessageRecipient::update($id, $fields); } mysql_free_result($rs); if ($email_current_hour) { $current_fields = DAO_Stats::get(0); $fields = array(DAO_Stats::EMAIL_CURRENT_HOUR => $current_fields->email_current_hour + $email_current_hour, DAO_Stats::EMAIL_SENT_TODAY => $current_fields->email_sent_today + $email_sent_today); DAO_Stats::update(0, $fields); } $timeout = ini_get('max_execution_time'); $runtime = microtime(true); return NULL; }