function getMailer($mailing, $html = 0) { $fromname = $mailing->fromname; $fromemail = trim($mailing->fromemail); $frombounce = empty($mailing->frombounce) ? trim($GLOBALS[ACA . 'confirm_return']) : trim($mailing->frombounce); $attachments = $mailing->attachments; $images = $mailing->images; if (ACA_CMSTYPE) { // joomla 15 $conf =& JFactory::getConfig(); $frombounceName = $fromname ? $fromname : $conf->getValue('config.fromname'); if (empty($fromemail)) { $fromemail = trim($conf->getValue('config.mailfrom')); } if (empty($fromname)) { $fromname = trim($conf->getValue('config.fromname')); } } else { //joomla 1x $frombounceName = $fromname ? $fromname : $GLOBALS['mosConfig_fromname']; if (empty($fromemail)) { $fromemail = trim($GLOBALS['mosConfig_mailfrom']); } if (empty($fromname)) { $fromname = trim($GLOBALS['mosConfig_fromname']); } } //endif if (ACA_CMSTYPE) { jimport('joomla.mail.mail'); $phpmailerPath = JPATH_LIBRARIES . DS . 'phpmailer' . DS; //require_once( $phpmailerPath . 'phpmailer.php' ); $mail = new JMail(); } else { $phpmailerPath = ACA_JPATH_ROOT_NO_ADMIN . DS . 'includes' . DS . 'phpmailer' . DS; require_once $phpmailerPath . 'class.phpmailer.php'; $mail = new mosPHPMailer(); $mail->CharSet = substr_replace(_ISO, '', 0, 8); } $mail->PluginDir = $phpmailerPath; $mail->SetLanguage('en', $phpmailerPath . 'language' . DS); $mail->WordWrap = 150; //$mail->addCustomHeader("X-Mailer: ".$GLOBALS[ACA.'component'].$GLOBALS[ACA.'version']); $mail->addCustomHeader("X-Mailer: " . ACA_JPATH_LIVE); $mail->addCustomHeader("X-MessageID: {$mailing->id}"); if ($GLOBALS[ACA . 'mail_format'] == '1') { $mail->Encoding = 'base64'; } if ($GLOBALS[ACA . 'minisendmail']) { $frombounceName = ''; } if (ACA_CMSTYPE) { $mail->addReplyTo(array($frombounce, $frombounceName)); } else { $mail->AddReplyTo($frombounce, $frombounceName); } $mail->From = trim($fromemail); if ($GLOBALS[ACA . 'minisendmail']) { $mail->FromName = ''; } else { $mail->FromName = $fromname; } $mail->Sender = trim($GLOBALS[ACA . 'sendmail_from']); if (empty($mail->Sender)) { $mail->Sender = ''; } switch ($GLOBALS[ACA . 'emailmethod']) { case 'mail': $mail->IsMail(); break; case 'sendmail': $mail->IsSendmail(); if (ACA_CMSTYPE) { // joomla 15 $conf =& JFactory::getConfig(); $mail->Sendmail = $GLOBALS[ACA . 'sendmail_path'] ? $GLOBALS[ACA . 'sendmail_path'] : $conf->getValue('config.sendmail'); } else { //joomla 1x $mail->Sendmail = $GLOBALS[ACA . 'sendmail_path'] ? $GLOBALS[ACA . 'sendmail_path'] : $GLOBALS['mosConfig_sendmail']; } //endif break; case 'smtp': $mail->IsSMTP(); if (ACA_CMSTYPE) { // joomla 15 $conf =& JFactory::getConfig(); $mail->Host = $GLOBALS[ACA . 'smtp_host'] ? $GLOBALS[ACA . 'smtp_host'] : $conf->getValue('config.smtphost'); } else { //joomla 1x $mail->Host = $GLOBALS[ACA . 'smtp_host'] ? $GLOBALS[ACA . 'smtp_host'] : $GLOBALS['mosConfig_smtphost']; } //endif if ((bool) $GLOBALS[ACA . 'smtp_auth_required']) { $mail->SMTPAuth = $GLOBALS[ACA . 'smtp_auth_required']; $mail->Password = $GLOBALS[ACA . 'smtp_password']; $mail->Username = $GLOBALS[ACA . 'smtp_username']; } break; default: if (ACA_CMSTYPE) { // joomla 15 $conf =& JFactory::getConfig(); $mail->Mailer = $conf->getValue('config.mailer'); // $GLOBALS['mosConfig_mailer']; } else { //joomla 1x $mail->Mailer = $GLOBALS['mosConfig_mailer']; } //endif break; } if (!empty($attachments)) { foreach ($attachments as $attachment) { if (basename($attachment) !== 'index.html') { $mail->AddAttachment(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . '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; }
function getMailer($mailing, $html = 0) { global $_VERSION; $joomAca15 = $_VERSION->RELEASE != '1.0' && class_exists('JFactory') ? true : false; $fromname = $mailing->fromname; $fromemail = trim($mailing->fromemail); $frombounce = empty($mailing->frombounce) ? trim($GLOBALS[ACA . 'confirm_return']) : trim($mailing->frombounce); $frombounceName = $fromname ? $fromname : $GLOBALS['mosConfig_fromname']; $attachments = $mailing->attachments; $images = $mailing->images; if (empty($fromemail)) { $fromemail = trim($GLOBALS['mosConfig_mailfrom']); } if (empty($fromname)) { $fromname = trim($GLOBALS['mosConfig_fromname']); } if ($joomAca15) { jimport('joomla.mail.mail'); $phpmailerPath = JPATH_LIBRARIES . DS . 'phpmailer' . DS; //require_once( $phpmailerPath . 'phpmailer.php' ); $mail = new JMail(); } else { $phpmailerPath = JPATH_ROOT . DS . 'includes' . DS . 'phpmailer' . DS; require_once $phpmailerPath . 'class.phpmailer.php'; $mail = new mosPHPMailer(); $mail->CharSet = substr_replace(_ISO, '', 0, 8); } $mail->PluginDir = $phpmailerPath; $mail->SetLanguage('en', $phpmailerPath . 'language' . DS); $mail->WordWrap = 150; //$mail->addCustomHeader("X-Mailer: ".$GLOBALS[ACA.'component'].$GLOBALS[ACA.'version']); $mail->addCustomHeader("X-Mailer: " . $GLOBALS['mosConfig_live_site']); $mail->addCustomHeader("X-MessageID: {$mailing->id}"); if ($GLOBALS[ACA . 'mail_format'] == '1') { $mail->Encoding = 'base64'; } if ($joomAca15) { $mail->addReplyTo(array($frombounce, $frombounceName)); } else { $mail->AddReplyTo($frombounce, $frombounceName); } $mail->From = trim($fromemail); $mail->FromName = $fromname; $mail->Sender = trim($GLOBALS[ACA . 'sendmail_from']); if (empty($mail->Sender)) { $mail->Sender = trim($GLOBALS['mosConfig_mailfrom']); } switch ($GLOBALS[ACA . 'emailmethod']) { case 'mail': $mail->IsMail(); break; case 'sendmail': $mail->IsSendmail(); $mail->Sendmail = $GLOBALS[ACA . 'sendmail_path'] ? $GLOBALS[ACA . 'sendmail_path'] : $GLOBALS['mosConfig_sendmail']; break; case 'smtp': $mail->IsSMTP(); $mail->Host = $GLOBALS[ACA . 'smtp_host'] ? $GLOBALS[ACA . 'smtp_host'] : $GLOBALS['mosConfig_smtphost']; if ((bool) $GLOBALS[ACA . 'smtp_auth_required']) { $mail->SMTPAuth = $GLOBALS[ACA . 'smtp_auth_required']; $mail->Password = $GLOBALS[ACA . 'smtp_password']; $mail->Username = $GLOBALS[ACA . 'smtp_username']; } break; default: $mail->Mailer = $GLOBALS['mosConfig_mailer']; break; } if (!empty($attachments)) { foreach ($attachments as $attachment) { if (basename($attachment) !== 'index.html') { $mail->AddAttachment($GLOBALS['mosConfig_absolute_path'] . $GLOBALS[ACA . '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; }
/** * Function to create a mail object for futher use (uses phpMailer) * @param string From e-mail address * @param string From name * @param string E-mail subject * @param string Message body * @return object Mail object */ function mosCreateMail($from = '', $fromname = '', $subject, $body) { global $mosConfig_absolute_path, $mosConfig_sendmail; global $mosConfig_smtpauth, $mosConfig_smtpuser; global $mosConfig_smtppass, $mosConfig_smtphost; global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailer; $mail = new mosPHPMailer(); $mail->PluginDir = $mosConfig_absolute_path . '/includes/phpmailer/'; $mail->SetLanguage('en', $mosConfig_absolute_path . '/includes/phpmailer/language/'); $mail->CharSet = substr_replace(_ISO, '', 0, 8); $mail->IsMail(); $mail->From = $from ? $from : $mosConfig_mailfrom; $mail->FromName = $fromname ? $fromname : $mosConfig_fromname; $mail->Mailer = $mosConfig_mailer; // Add smtp values if needed if ($mosConfig_mailer == 'smtp') { $mail->SMTPAuth = $mosConfig_smtpauth; $mail->Username = $mosConfig_smtpuser; $mail->Password = $mosConfig_smtppass; $mail->Host = $mosConfig_smtphost; } else { // Set sendmail path if ($mosConfig_mailer == 'sendmail') { if (isset($mosConfig_sendmail)) { $mail->Sendmail = $mosConfig_sendmail; } } } // if $mail->Subject = $subject; $mail->Body = $body; return $mail; }