Example #1
0
 function sendMail()
 {
     global $toC_Json, $osC_Language;
     $to = array();
     $emails = explode(';', $_REQUEST['to']);
     foreach ($emails as $email) {
         if (!empty($email)) {
             $to[] = osC_Mail::parseEmail($email);
         }
     }
     $cc = array();
     if (isset($_REQUEST['cc']) && !empty($_REQUEST['cc'])) {
         $emails = explode(';', $_REQUEST['cc']);
         foreach ($emails as $email) {
             if (!empty($email)) {
                 $cc[] = osC_Mail::parseEmail($email);
             }
         }
     }
     $bcc = array();
     if (isset($_REQUEST['bcc']) && !empty($_REQUEST['bcc'])) {
         $emails = explode(';', $_REQUEST['bcc']);
         foreach ($emails as $email) {
             if (!empty($email)) {
                 $bcc[] = osC_Mail::parseEmail($email);
             }
         }
     }
     $attachments = array();
     if (isset($_REQUEST['attachments']) && !empty($_REQUEST['attachments'])) {
         $attachments = explode(';', $_REQUEST['attachments']);
     }
     $toC_Email_Account = new toC_Email_Account($_REQUEST['accounts_id']);
     $data = array('accounts_id' => $toC_Email_Account->getAccountId(), 'id' => $_REQUEST['id'], 'to' => $to, 'cc' => $cc, 'bcc' => $bcc, 'from' => $toC_Email_Account->getAccountName(), 'sender' => $toC_Email_Account->getAccountEmail(), 'subject' => $_REQUEST['subject'], 'reply_to' => $toC_Email_Account->getAccountEmail(), 'full_from' => $toC_Email_Account->getAccountName() . ' <' . $toC_Email_Account->getAccountEmail() . '>', 'body' => $_REQUEST['body'], 'priority' => $_REQUEST['priority'], 'content_type' => $_REQUEST['content_type'], 'notification' => $_REQUEST['notification'], 'udate' => time(), 'date' => date('m/d/Y H:i:s'), 'fetch_timestamp' => time(), 'messages_flag' => EMAIL_MESSAGE_DRAFT, 'attachments' => $attachments);
     if ($toC_Email_Account->sendMail($data)) {
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
     }
     echo $toC_Json->encode($response);
 }