Joomla 1.6/1.7/2.5 Mail versand in verschiedenen Sprachen mittels JText

Januar 23rd, 2012

    public function addPosition($typ, $description, $comment ) {
          
        // Community Builder List
        $langUsers = array();
        $langUsers['de-DE'] = $this->_getUsers( array('Österreich', 'Schweiz', 'Deutschland'));
        $langUsers['en-GB'] = $this->_getUsers( array('Czech Republic'));
       
        foreach( $langUsers as $lang => $users ) {
       
            // Lade die Sprache
            $language = JLanguage::getInstance($lang);
            $language->load ('com_signalservice' );
            
            // Email Empfänger adressen auslesen
            $empfanger = array();
            foreach( $users as $user ) {
                $empfanger[] = $user['email'];
            }
            
            // Email Text bauen
            $subject = sprintf($language->_('NEW_POSITION_SUBJECT'), $typ);
            $body = sprintf($language->_('NEW_POSITION_BODY'), $newId, JTEXT::_($typ), $description );
            if($comment != null && $comment != '' ) 
                    $body .= sprintf($language->_('NEW_POSITION_BODY_COMMENT'), $comment);
            
            // E-Mail schreiben
            $this->_writeMails($empfanger, $subject, $body );
        
        }
    
    }

    protected function _writeMails($empfanger, $subject, $body ) {
    
        // mailer
        $mailer =& JFactory::getMailer();
        $config =& JFactory::getConfig();
        
        // sender
        $sender = array( 
            $config->getValue( 'config.mailfrom' ),
            $config->getValue( 'config.fromname' ) );
        $mailer->setSender($sender);
        
        // empfänger
        $mailer->addRecipient( $empfanger );
    
        // betreff
        $mailer->setSubject( $subject );
    
        $mailer->isHTML(true);
        $mailer->Encoding = 'base64';
        $mailer->setBody($body);

        // senden
       return $mailer->Send();
    
    }

Tags: , , , , , , , , ,

Comments are closed.