Example #1
0
 /**
  * @param string $sFrom
  * @param string $sTo
  * @param string $sSubject
  * @param string $sCc Default value is empty string.
  * @param string $sBcc Default value is empty string.
  * @param string $sMessageID Default value is empty string.
  * @param string $sReferences Default value is empty string.
  *
  * @return \MailSo\Mime\Message
  */
 private function _buildMail($sFrom, $sTo, $sSubject, $sCc = '', $sBcc = '', $sMessageID = '', $sReferences = '')
 {
     $oMessage = \MailSo\Mime\Message::NewInstance();
     if (empty($sMessageID)) {
         $oMessage->RegenerateMessageId();
     } else {
         $oMessage->SetMessageId($sMessageID);
     }
     if (!empty($sReferences)) {
         $oMessage->SetReferences($sReferences);
     }
     $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
     if (0 < strlen($sXMailer)) {
         $oMessage->SetXMailer($sXMailer);
     }
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($sFrom))->SetSubject($sSubject);
     $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($sTo);
     if ($oToEmails && $oToEmails->Count()) {
         $oMessage->SetTo($oToEmails);
     }
     $oCcEmails = \MailSo\Mime\EmailCollection::NewInstance($sCc);
     if ($oCcEmails && $oCcEmails->Count()) {
         $oMessage->SetCc($oCcEmails);
     }
     $oBccEmails = \MailSo\Mime\EmailCollection::NewInstance($sBcc);
     if ($oBccEmails && $oBccEmails->Count()) {
         $oMessage->SetBcc($oBccEmails);
     }
     return $oMessage;
 }
Example #2
0
 /**
  * @return array
  */
 public function AjaxAccountResetPassword()
 {
     $mResult = false;
     $oAccount = $this->getDefaultAccountFromParam();
     $sUrlHash = $this->getParamValue('UrlHash', '');
     $oTenant = null;
     if ($oAccount->Domain->IdTenant > 0) {
         $oTenant = $this->oApiTenants->getTenantById($oAccount->Domain->IdTenant);
     } else {
         $oTenant = $this->oApiTenants->getDefaultGlobalTenant();
     }
     if ($oTenant) {
         $oNotificationAccount = $this->oApiUsers->GetAccountByEmail($oTenant->InviteNotificationEmailAccount);
         if ($oNotificationAccount) {
             $sPasswordResetUrl = rtrim(\api_Utils::GetAppUrl(), '/');
             $sPasswordResetHash = \md5(\time() . \rand(1000, 9999) . \CApi::$sSalt);
             $oAccount->User->PasswordResetHash = $sPasswordResetHash;
             $this->oApiUsers->updateAccount($oAccount);
             $sSubject = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/SUBJECT', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName));
             $sBody = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/BODY', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName, 'PASSWORD_RESET_URL' => $sPasswordResetUrl . '/?reset-pass='******'#' . $sUrlHash, 'EMAIL' => $oAccount->Email));
             $oMessage = \MailSo\Mime\Message::NewInstance();
             $oMessage->RegenerateMessageId();
             $oMessage->DoesNotCreateEmptyTextPart();
             $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
             if (0 < strlen($sXMailer)) {
                 $oMessage->SetXMailer($sXMailer);
             }
             $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oTenant->InviteNotificationEmailAccount))->SetSubject($sSubject)->AddText($sBody, true);
             $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($oAccount->Email);
             if ($oToEmails && $oToEmails->Count()) {
                 $oMessage->SetTo($oToEmails);
             }
             if ($oMessage) {
                 try {
                     $mResult = $this->oApiMail->sendMessage($oNotificationAccount, $oMessage);
                 } catch (\CApiManagerException $oException) {
                     throw $oException;
                 }
             }
         }
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }
Example #3
0
 /**
  * @param CAccount $oAccount
  * @param string $sSubject
  * @param string $mHtml = null
  * @param string $mText = null
  *
  * @return \MailSo\Mime\Message
  */
 private function createMessage($oAccount, $sSubject, $mHtml = null, $mText = null)
 {
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $sXMailer = CApi::GetConf('webmail.xmailer-value', '');
     if (0 < strlen($sXMailer)) {
         $oMessage->SetXMailer($sXMailer);
     }
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oAccount->Email))->SetSubject($sSubject);
     $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($oAccount->Email);
     if ($oToEmails && $oToEmails->Count()) {
         $oMessage->SetTo($oToEmails);
     }
     if ($mHtml !== null) {
         $oMessage->AddText($mHtml, true);
     }
     if ($mText !== null) {
         $oMessage->AddText($mText, false);
     }
     return $oMessage;
 }
 /**
  * @param \RainLoop\Model\Account $oAccount
  *
  * @return \MailSo\Mime\Message
  */
 private function buildReadReceiptMessage($oAccount)
 {
     $sReadReceipt = $this->GetActionParam('ReadReceipt', '');
     $sSubject = $this->GetActionParam('Subject', '');
     $sText = $this->GetActionParam('Text', '');
     $oIdentity = $this->GetAccountIdentity($oAccount);
     if (empty($sReadReceipt) || empty($sSubject) || empty($sText) || !$oIdentity) {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::UnknownError);
     }
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $oMessage->SetXMailer('RainLoop/' . APP_VERSION);
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oIdentity->Email(), $oIdentity->Name()));
     $sReplyTo = $oIdentity->ReplyTo();
     if (!empty($sReplyTo)) {
         $oReplyTo = \MailSo\Mime\EmailCollection::NewInstance($sReplyTo);
         if ($oReplyTo && $oReplyTo->Count()) {
             $oMessage->SetReplyTo($oReplyTo);
         }
     }
     $oMessage->SetSubject($sSubject);
     $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($sReadReceipt);
     if ($oToEmails && $oToEmails->Count()) {
         $oMessage->SetTo($oToEmails);
     }
     $this->Plugins()->RunHook('filter.read-receipt-message-plain', array($oAccount, &$oMessage, &$sText));
     $oMessage->AddText($sText, false);
     $this->Plugins()->RunHook('filter.build-read-receipt-message', array(&$oMessage, $oAccount));
     return $oMessage;
 }
Example #5
0
 /**
  * @param \CAccount $oAccount
  *
  * @return \MailSo\Mime\Message
  *
  * @throws \MailSo\Base\Exceptions\InvalidArgumentException
  */
 private function buildConfirmationMessage($oAccount)
 {
     $sConfirmation = $this->getParamValue('Confirmation', '');
     $sSubject = $this->getParamValue('Subject', '');
     $sText = $this->getParamValue('Text', '');
     if (0 === strlen($sConfirmation) || 0 === strlen($sSubject) || 0 === strlen($sText)) {
         throw new \MailSo\Base\Exceptions\InvalidArgumentException();
     }
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
     if (0 < strlen($sXMailer)) {
         $oMessage->SetXMailer($sXMailer);
     }
     $oTo = \MailSo\Mime\EmailCollection::Parse($sConfirmation);
     if (!$oTo || 0 === $oTo->Count()) {
         throw new \MailSo\Base\Exceptions\InvalidArgumentException();
     }
     $sFrom = 0 < strlen($oAccount->FriendlyName) ? '"' . $oAccount->FriendlyName . '"' : '';
     if (0 < strlen($sFrom)) {
         $sFrom .= ' <' . $oAccount->Email . '>';
     } else {
         $sFrom .= $oAccount->Email;
     }
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($sFrom))->SetTo($oTo)->SetSubject($sSubject);
     $oMessage->AddText($sText, false);
     return $oMessage;
 }