Exemple #1
0
 /** __construct()
  * @param string subject
  * @param mixed Template|String
  * @param boolean is html email
  * @param boolean use multi part
  *
  * @return void
  */
 public function __construct($sSubject, $oContent = null, $bIsHtml = false)
 {
     $this->aRecipients = array();
     $this->aCarbonCopyRecipients = array();
     $this->aBlindCarbonCopyRecipients = array();
     if ($oContent instanceof Template) {
         $this->sCharset = $oContent->getCharset();
     } else {
         $this->sCharset = Settings::getSetting('encoding', 'db', 'utf-8');
     }
     $this->sMimeType = 'text/plain';
     if ($bIsHtml) {
         $this->sMimeType = 'text/html';
     }
     $this->oContent = $oContent;
     $this->sSenderName = null;
     $this->sSenderAddress = LinkUtil::getDomainHolderEmail('mailer-daemon');
     $this->oFlash = new Flash();
     $this->sReplyTo = null;
     $this->sSubject = $sSubject;
 }
 /**
  * sendMail()
  */
 private function sendMail($oEmailTemplate, $bSendHtml = false)
 {
     $oEmailTemplate->replaceIdentifier('name', $this->oSubscriber->getName());
     $sSenderName = Settings::getSetting('newsletter', 'sender_name', 'Rapila Newsletter Plugin');
     $sSenderEmail = Settings::getSetting('newsletter', 'sender_email', LinkUtil::getDomainHolderEmail('no-reply'));
     $oEmailTemplate->replaceIdentifier('signature', $sSenderName);
     $oEmailTemplate->replaceIdentifier('weblink', LinkUtil::getHostName());
     $oEmail = new EMail(TranslationPeer::getString('wns.subscriber_email.subject'), $oEmailTemplate, $bSendHtml);
     $oEmail->setSender($sSenderName, $sSenderEmail);
     $oEmail->addRecipient($this->oSubscriber->getEmail());
     $oEmail->send();
 }
Exemple #3
0
 public static function sendResetMail($oUser, $bShowUserName = false, $sLinkBase = null, $bForceReset = false)
 {
     UserPeer::ignoreRights(true);
     $oUser->setPasswordRecoverHint(PasswordHash::generateHint());
     $oUser->save();
     $oEmailTemplate = new Template('e_mail_pw_recover', array(DIRNAME_TEMPLATES, 'login'));
     $oEmailTemplate->replaceIdentifier('full_name', $oUser->getFullName());
     $oEmailTemplate->replaceIdentifier('first_name', $oUser->getFirstName());
     $oEmailTemplate->replaceIdentifier('last_name', $oUser->getLastName());
     $oEmailTemplate->replaceIdentifier('username', $oUser->getUsername());
     if ($bShowUserName) {
         $oEmailTemplate->replaceIdentifier('username_info', TranslationPeer::getString('wns.login.password_reset.your_username') . ': ' . $oUser->getUsername());
     }
     $sInfoTextKey = 'wns.login.password_recover_email_text2';
     if ($bForceReset) {
         $sInfoTextKey = 'wns.login.password_recover_email_text2_force';
     }
     $oEmailTemplate->replaceIdentifier('ignore_or_reset_info', TranslationPeer::getString($sInfoTextKey));
     if ($sLinkBase === null) {
         if (Manager::$CURRENT_MANAGER instanceof FrontendManager) {
             // We’re most likely on a login page: link to self should be ok
             $sLinkBase = LinkUtil::linkToSelf(null, null, true);
         } else {
             // Use the login manager
             $sLinkBase = LinkUtil::link(array(), 'LoginManager');
         }
     }
     $aParams = array('recover_hint' => md5($oUser->getPasswordRecoverHint()), 'recover_username' => $oUser->getUsername());
     if (Session::getSession()->hasAttribute('login_referrer')) {
         $aParams['recover_referrer'] = Session::getSession()->getAttribute('login_referrer');
     }
     $sLink = "http://" . $_SERVER['HTTP_HOST'] . $sLinkBase . LinkUtil::prepareLinkParameters($aParams);
     $oEmailTemplate->replaceIdentifier('new_pw_url', $sLink);
     $oEmail = new EMail(TranslationPeer::getString('wns.login.password_recover_email_subject'), $oEmailTemplate);
     $sSenderAddress = LinkUtil::getDomainHolderEmail('cms');
     $oEmail->setSender(Settings::getSetting('domain_holder', 'name', 'rapila on ' . $_SERVER['HTTP_HOST']), $sSenderAddress);
     $oEmail->addRecipient($oUser->getEmail(), $oUser->getFullName());
     $oEmail->send();
 }
 /** prepareForSending()
  *
  * @param array of mail_group values [int subscriber_group_id, string external_mail_group]
  * @param string SenderMail
  * @param string SenderName
  *
  * description: prepare batch processing
  * • validates send form
  *
  * @return int batch count
  */
 public function prepareForSending($aMailGroups = null, $sSenderEmail = null, $sSenderName = null)
 {
     if (!$sSenderEmail) {
         $sSenderEmail = LinkUtil::getDomainHolderEmail('newsletter');
     }
     $this->sSenderEmail = $sSenderEmail;
     if ($sSenderName !== $sSenderEmail) {
         $this->sSenderName = $sSenderName;
     }
     $this->aRecipients = self::getSubscribersBySubscriberGroupMembership($aMailGroups);
     FilterModule::getFilters()->handleMailGroupsRecipients($aMailGroups, array(&$this->aRecipients));
     // Validate prepareForSending
     $sError = null;
     if ($aMailGroups === null) {
         $sError = 'mail_group_required';
     } else {
         if (count($this->aRecipients) === 0) {
             $sError = 'no_recipients_available';
         }
     }
     $oFlash = new Flash();
     if ($sError) {
         $oFlash->addMessage($sError);
     }
     $oFlash->finishReporting();
     if ($oFlash->hasMessages()) {
         throw new ValidationException($oFlash);
     }
     $this->aMailGroups = is_array($aMailGroups) ? $aMailGroups : array($aMailGroups);
     return ceil(count($this->aRecipients) / $this->iBatchSize);
 }