Ejemplo n.º 1
0
 function getMailer()
 {
     if (!FSS_Settings::Get('email_send_override')) {
         $mailer = JFactory::getMailer();
         $mailer->setSender($this->Get_Sender());
         $mailer->CharSet = 'UTF-8';
         return $mailer;
     }
     $smtpauth = FSS_Settings::Get('email_send_smtp_auth') == 0 ? null : 1;
     $smtpuser = FSS_Settings::Get('email_send_smtp_username');
     // $conf->get('smtpuser');
     $smtppass = FSS_Settings::Get('email_send_smtp_password');
     // $conf->get('smtppass');
     $smtphost = FSS_Settings::Get('email_send_smtp_host');
     // $conf->get('smtphost');
     $smtpsecure = FSS_Settings::Get('email_send_smtp_security');
     // $conf->get('smtpsecure');
     $smtpport = FSS_Settings::Get('email_send_smtp_port');
     // $conf->get('smtpport');
     $mailfrom = FSS_Settings::Get('email_send_from_email');
     // $conf->get('mailfrom');
     $fromname = FSS_Settings::Get('email_send_from_name');
     // $conf->get('fromname');
     $mailer = FSS_Settings::Get('email_send_mailer');
     // $conf->get('mailer');
     // Create a JMail object
     $mail = new JMail();
     // Set default sender without Reply-to
     $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     $mail->CharSet = 'UTF-8';
     return $mail;
 }
Ejemplo n.º 2
0
 /**
  * This function is used to override the send function in Joomla
  */
 public static function getMailer($mailing, $html = 0)
 {
     $fromname = empty($mailing->fromname) ? trim($GLOBALS[JNEWS . 'sendmail_name']) : trim($mailing->fromname);
     $fromemail = empty($mailing->fromemail) ? trim($GLOBALS[JNEWS . 'sendmail_email']) : trim($mailing->fromemail);
     $frombounce = empty($mailing->frombounce) ? trim($GLOBALS[JNEWS . 'sendmail_from']) : trim($mailing->frombounce);
     if (empty($fromemail)) {
         $my = JFactory::getUser();
         $userSender = jNews_Subscribers::getUsers('gid', '50', $my->id);
         $fromemail = $userSender[0]->email;
         if (empty($fromemail)) {
             jnews::printM('no', 'The sender email needs to be specified in the configuration.');
             return false;
         }
     }
     if (empty($frombounce)) {
         $frombounce = $fromemail;
     }
     $attachments = $mailing->attachments;
     $images = $mailing->images;
     $conf = JFactory::getConfig();
     $frombounceName = $fromname ? $fromname : $conf->get('config.fromname');
     if (empty($fromemail)) {
         $fromemail = trim($conf->get('config.mailfrom'));
     }
     if (empty($fromname)) {
         $fromname = trim($conf->get('config.fromname'));
     }
     jimport('joomla.mail.mail');
     $phpmailerPath = JPATH_LIBRARIES . DS . 'phpmailer' . DS;
     $mail = new JMail();
     $mail->PluginDir = $phpmailerPath;
     $mail->SetLanguage('en', $phpmailerPath . 'language' . DS);
     $mail->WordWrap = 150;
     //      	$mail->addCustomHeader("X-Mailer: ".JNEWS_JPATH_LIVE);
     //      	$mail->addCustomHeader("X-MessageID: $mailing->id");
     if ($GLOBALS[JNEWS . 'mail_format'] == '1') {
         $mail->Encoding = 'base64';
     }
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $frombounceName = '';
     }
     if (!empty($frombounce)) {
         if (version_compare(JVERSION, '3.0.0', '<')) {
             $mail->addReplyTo(array($frombounce, $frombounceName));
         } else {
             $mail->addReplyTo(array($frombounce));
         }
         JRequest::setVar('bounceBackEmail', $frombounce);
     }
     $mail->From = trim($fromemail);
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $mail->FromName = '';
     } else {
         $mail->FromName = $fromname;
     }
     $mail->Sender = trim($GLOBALS[JNEWS . 'sendmail_from']);
     if (empty($mail->Sender)) {
         $mail->Sender = '';
     }
     switch ($GLOBALS[JNEWS . 'emailmethod']) {
         case 'mail':
             $mail->IsMail();
             break;
         case 'sendmail':
             $mail->IsSendmail();
             $mail->Sendmail = $GLOBALS[JNEWS . 'sendmail_path'] ? $GLOBALS[JNEWS . 'sendmail_path'] : $conf->get('config.sendmail');
             break;
         case 'smtp':
             $mail->IsSMTP();
             $mail->Host = $GLOBALS[JNEWS . 'smtp_host'] ? $GLOBALS[JNEWS . 'smtp_host'] : $conf->get('config.smtphost');
             $mail->Port = $GLOBALS[JNEWS . 'smtp_port'] ? $GLOBALS[JNEWS . 'smtp_port'] : $conf->get('config.smtpport');
             $mail->SMTPSecure = $GLOBALS[JNEWS . 'smtp_secure'] ? $GLOBALS[JNEWS . 'smtp_secure'] : '';
             if ((bool) $GLOBALS[JNEWS . 'smtp_auth_required']) {
                 $mail->SMTPAuth = $GLOBALS[JNEWS . 'smtp_auth_required'];
                 $mail->Password = $GLOBALS[JNEWS . 'smtp_password'];
                 $mail->Username = $GLOBALS[JNEWS . 'smtp_username'];
             }
             break;
         default:
             $mail->Mailer = $conf->get('config.mailer');
             break;
     }
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (basename($attachment) !== 'index.html') {
                 $mail->AddAttachment(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . DS . basename($attachment));
             }
         }
     }
     switch (substr(strtoupper(PHP_OS), 0, 3)) {
         case "WIN":
             $mail->LE = "\r\n";
             break;
         case "MAC":
         case "DAR":
             $mail->LE = "\r";
         default:
             break;
     }
     return $mail;
 }