Example #1
0
 function &getChildInstance($id = 'Joomla')
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     if (empty($instances[$id])) {
         $conf =& JFactory::getConfig();
         $sendmail = $conf->getValue('config.sendmail');
         if (JLMS_J16version()) {
             $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
         } else {
             $smtpauth = $conf->getValue('config.smtpauth');
         }
         $smtpuser = $conf->getValue('config.smtpuser');
         $smtppass = $conf->getValue('config.smtppass');
         $smtphost = $conf->getValue('config.smtphost');
         $smtpsecure = $conf->getValue('config.smtpsecure');
         $smtpport = $conf->getValue('config.smtpport');
         $mailfrom = $conf->getValue('config.mailfrom');
         $fromname = $conf->getValue('config.fromname');
         $mailer = $conf->getValue('config.mailer');
         $instance = new MailManager();
         // Set default sender
         $instance->setSender(array($mailfrom, $fromname));
         // Default mailer is to use PHP's mail function
         switch ($mailer) {
             case 'smtp':
                 $instance->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
                 break;
             case 'sendmail':
                 $instance->useSendmail($sendmail);
                 break;
             default:
                 $instance->IsMail();
                 break;
         }
         $instances[$id] = $instance;
     }
     return $instances[$id];
 }