Example #1
0
 public function save($request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $to_email = $currentUser->get('email1');
     if ($to_email != '') {
         $data = array('id' => 95, 'to_email' => $to_email, 'module' => 'Users', 'record' => $currentUser->getId());
         $recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
         $mail_status = $recordModel->sendMailFromTemplate($data);
     }
     if ($mail_status != 1 && !$this->isDefaultSettingLoaded()) {
         throw new Exception('Error occurred while sending mail');
     }
     return parent::save();
 }
 public function save($request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $toEmail = $currentUser->get('email1');
     if (!empty($toEmail)) {
         $data = ['sysname' => 'TestMailAboutTheMailServerConfiguration', 'to_email' => $toEmail, 'module' => 'Users', 'record' => $currentUser->getId()];
         $recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
         $mailStatus = $recordModel->sendMailFromTemplate($data);
     }
     if ($mailStatus != 1 && !$this->isDefaultSettingLoaded()) {
         throw new Exception('Error occurred while sending mail');
     }
     return parent::save();
 }
Example #3
0
 public function save($request)
 {
     vimport('~~/modules/Emails/mail.php');
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $from_email = $request->get('from_email_field');
     $to_email = getUserEmailId('id', $currentUser->getId());
     $subject = $this->getSubject();
     $description = $this->getBody();
     // This is added so that send_mail API will treat it as user initiated action
     $olderAction = $_REQUEST['action'];
     $_REQUEST['action'] = 'Save';
     if ($to_email != '') {
         $mail_status = send_mail('Users', $to_email, $currentUser->get('user_name'), $from_email, $subject, $description, '', '', '', '', '', true);
     }
     $_REQUEST['action'] = $olderAction;
     if ($mail_status != 1 && !$this->isDefaultSettingLoaded()) {
         throw new Exception('Error occurred while sending mail');
     }
     return parent::save();
 }