Beispiel #1
1
 /**
  * Do a batch send
  */
 function send($total = 100)
 {
     $mailqModel = CFactory::getModel('mailq');
     $userModel = CFactory::getModel('user');
     $mails = $mailqModel->get($total);
     $jconfig = JFactory::getConfig();
     $mailer = JFactory::getMailer();
     $config = CFactory::getConfig();
     $senderEmail = $jconfig->getValue('mailfrom');
     $senderName = $jconfig->getValue('fromname');
     if (empty($mails)) {
         return;
     }
     CFactory::load('helpers', 'string');
     foreach ($mails as $row) {
         // @rule: only send emails that is valid.
         // @rule: make sure recipient is not blocked!
         $userid = $userModel->getUserFromEmail($row->recipient);
         $user = CFactory::getUser($userid);
         if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
             $mailer->setSender(array($senderEmail, $senderName));
             $mailer->addRecipient($row->recipient);
             $mailer->setSubject($row->subject);
             $tmpl = new CTemplate();
             $raw = isset($row->params) ? $row->params : '';
             $params = new JParameter($row->params);
             $base = $config->get('htmlemail') ? 'email.html' : 'email.text';
             if ($config->get('htmlemail')) {
                 $row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
                 $mailer->IsHTML(true);
             } else {
                 //@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
                 $row->body = CStringHelper::escape(strip_tags($row->body));
             }
             $tmpl->set('content', $row->body);
             $tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
             $tmpl->set('sitename', $config->get('sitename'));
             $row->body = $tmpl->fetch($base);
             // Replace any occurences of custom variables within the braces scoe { }
             if (!empty($row->body)) {
                 preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
                 foreach ($matches as $val) {
                     $replaceWith = $params->get($val[1], null);
                     //if the replacement start with 'index.php', we can CRoute it
                     if (strpos($replaceWith, 'index.php') === 0) {
                         $replaceWith = CRoute::getExternalURL($replaceWith);
                     }
                     if (!is_null($replaceWith)) {
                         $row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
                     }
                 }
             }
             unset($tmpl);
             $mailer->setBody($row->body);
             $mailer->send();
         }
         $mailqModel->markSent($row->id);
         $mailer->ClearAllRecipients();
     }
 }
Beispiel #2
1
 function send($message)
 {
     global $mainframe;
     if (empty($message)) {
         $this->setError(JText::_('The alert is empty'));
         return false;
     }
     if (is_array($message)) {
         $message = implode('<br /><br />', $message);
     }
     $recepients = $this->_getEmailsToSend();
     if (empty($recepients) || !count($recepients)) {
         $this->setError(JText::_('No recepients for email or bad emails'));
     }
     $mail =& JFactory::getMailer();
     $mail->addRecipient($recepients);
     $sender = $this->_getSender();
     $mail->setSender($sender);
     $mail->addReplyTo($sender);
     $mail->isHTML(true);
     $params =& $this->_getParams();
     $subject = $params->get('alerts_mail_subject', 'Mighty Defender alert');
     $mail->setSubject($subject);
     $mail->setBody($message);
     if (!$mail->Send()) {
         $this->setError(JText::_('Failed sending mail'));
         return false;
     }
     return true;
 }
Beispiel #3
1
 public function sendVouchers($cids)
 {
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $params = J2Store::config();
     $sitename = $config->get('sitename');
     $emailHelper = J2Store::email();
     $mailfrom = $config->get('mailfrom');
     $fromname = $config->get('fromname');
     $failed = 0;
     foreach ($cids as $cid) {
         $voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone();
         $voucherTable->load($cid);
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->isHtml(true);
         $mailer->addRecipient($voucherTable->email_to);
         $mailer->setSubject($voucherTable->subject);
         // parse inline images before setting the body
         $emailHelper->processInlineImages($voucherTable->email_body, $mailer);
         $mailer->setBody($voucherTable->email_body);
         //Allow plugins to modify
         J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer));
         if ($mailer->Send() !== true) {
             $this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to));
             $failed++;
         }
         J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer));
         $mailer = null;
     }
     if ($failed > 0) {
         return false;
     }
     return true;
 }
Beispiel #4
0
 function onArrival($hookParameters, $workflow, $currentStation, $currentStep)
 {
     $pManager =& getPluginManager();
     $pManager->loadPlugins('acl');
     $tempResponse = null;
     $tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($currentStation->group));
     $userList = $tempResponse[$workflow->acl];
     $tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($workflow->admin_gid));
     $adminList = $tempResponse[$workflow->acl];
     $mail = JFactory::getMailer();
     if (intval($hookParameters->SendAdmin) && count($adminList)) {
         $mail->IsHTML(true);
         foreach ($adminList as $admin) {
             $mail->AddRecipient($admin->email);
         }
         $mail->SetSubject(JText::_('Item moved'));
         $translatedMessage = $this->_translate($hookParameters->AdminText, $hookParameters, $workflow, $currentStation, $currentStep);
         $mail->SetBody($translatedMessage);
         $mail->Send();
     }
     if (intval($hookParameters->SendUser) && count($userList)) {
         $mail->IsHTML(true);
         foreach ($userList as $user) {
             $mail->AddRecipient($user->email);
         }
         $mail->SetSubject(JText::_('New task awaits'));
         $translatedMessage = $this->_translate($hookParameters->UserText, $hookParameters, $workflow, $currentStation);
         $mail->SetBody($translatedMessage);
         $mail->Send();
     }
 }
Beispiel #5
0
 function sendMemberDaytimeToAdmin($member_id, $service_id, $daytime_id)
 {
     define("BodyMemberDaytimeToAdmin", "<h1>Nouvelle inscription à une tranche horaire</h1><p>Un bénévole s'est inscrit à un secteur / tranche horaire.</p><p><strong>Nom :</strong> %s <br /><strong>Secteur :</strong> %s<br /><strong>Date :</strong> %s<br /><strong>Tranche horaire :</strong> %s</p><p><a href=\"" . JURI::root() . "/administrator/index.php?option=com_estivole&view=member&layout=edit&member_id=%s\">Cliquez ici</a> pour valider l'inscription et/ou recontacter le bénévole.</p>");
     define("SubjectMemberDaytimeToAdmin", "Nouvelle inscription à une tranche horaire");
     $db = JFactory::getDBO();
     $query = $db->getQuery(TRUE);
     $this->user = JFactory::getUser();
     // Get the dispatcher and load the user's plugins.
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('user');
     $data = new JObject();
     $data->id = $this->user->id;
     // Trigger the data preparation event.
     $dispatcher->trigger('onContentPrepareData', array('com_users.profilestivole', &$data));
     $userProfilEstivole = $data;
     $userName = $userProfilEstivole->profilestivole['firstname'] . ' ' . $userProfilEstivole->profilestivole['lastname'];
     $query->select('*');
     $query->from('#__estivole_members as b, #__estivole_services as s, #__estivole_daytimes as d');
     $query->where('b.member_id = ' . (int) $member_id);
     $query->where('s.service_id = ' . (int) $service_id);
     $query->where('d.daytime_id = ' . (int) $daytime_id);
     $db->setQuery($query);
     $mailModel = $db->loadObject();
     $mail = JFactory::getMailer();
     $mail->setBody(sprintf(constant("BodyMemberDaytimeToAdmin"), $userName, $mailModel->service_name, date('d-m-Y', strtotime($mailModel->daytime_day)), date('H:i', strtotime($mailModel->daytime_hour_start)) . ' - ' . date('H:i', strtotime($mailModel->daytime_hour_end)), $mailModel->member_id));
     $mail->setSubject(constant("SubjectMemberDaytimeToAdmin"));
     $mail->isHtml();
     $recipient = array('*****@*****.**', $mailModel->email_responsable);
     $mail->addRecipient($recipient);
     $mail->Send('*****@*****.**');
 }
 /**
  * Entry point for the script
  *
  */
 public function doExecute()
 {
     $mailfrom = JFactory::getConfig()->get('mailfrom');
     $fromname = JFactory::getConfig()->get('fromname');
     $db = JFactory::getDbo();
     // Get plugin params
     $query = $db->getQuery(true);
     $query->select('params')->from('#__extensions')->where('element = ' . $db->quote('pfnotifications'))->where('type = ' . $db->quote('plugin'));
     $db->setQuery($query);
     $plg_params = $db->loadResult();
     $params = new JRegistry();
     $params->loadString($plg_params);
     $limit = (int) $params->get('cron_limit');
     // Get a list of emails to send
     $query->clear();
     $query->select('id, email, subject, message, created')->from('#__pf_emailqueue')->order('id ASC');
     $db->setQuery($query, 0, $limit);
     $items = $db->loadObjectList();
     if (!is_array($items)) {
         $items = array();
     }
     // Send and delete each email
     foreach ($items as $item) {
         $mailer = JFactory::getMailer();
         $mailer->sendMail($mailfrom, $fromname, $item->email, $item->subject, $item->message);
         $query->clear();
         $query->delete('#__pf_emailqueue')->where('id = ' . (int) $item->id);
         $db->setQuery($query);
         $db->execute();
     }
 }
Beispiel #7
0
 /**
  * Send email whith user data from form
  *
  * @param   array  $params An object containing the module parameters
  *
  * @access public
  */
 public static function sendMail($params)
 {
     $sender = $params->get('sender');
     $recipient = $params->get('recipient');
     $subject = $params->get('subject');
     // Getting the site name
     $sitename = JFactory::getApplication()->get('sitename');
     // Getting user form data-------------------------------------------------
     $name = JFilterInput::getInstance()->clean(JRequest::getVar('name'));
     $phone = JFilterInput::getInstance()->clean(JRequest::getVar('phone'));
     $email = JFilterInput::getInstance()->clean(JRequest::getVar('email'));
     $message = JFilterInput::getInstance()->clean(JRequest::getVar('message'));
     // Set the massage body vars
     $nameLabel = JText::_('MOD_JCALLBACK_FORM_NAME_LABEL_VALUE');
     $phoneLabel = JText::_('MOD_JCALLBACK_FORM_PHONE_LABEL_VALUE');
     $emailLabel = JText::_('MOD_JCALLBACK_FORM_EMAIL_LABEL_VALUE');
     $messageLabel = JText::_('MOD_JCALLBACK_FORM_MESSAGE_LABEL_VALUE');
     $emailLabel = $email ? "<b>{$emailLabel}:</b> {$email}" : "";
     $messageLabel = $message ? "<b>{$messageLabel}:</b> {$message}" : "";
     // Get the JMail ogject
     $mailer = JFactory::getMailer();
     // Set JMail object params------------------------------------------------
     $mailer->setSubject($subject);
     $params->get('useSiteMailfrom') ? $mailer->setSender(JFactory::getConfig()->get('mailfrom')) : $mailer->setSender($sender);
     $mailer->addRecipient($recipient);
     // Get the mail message body
     require JModuleHelper::getLayoutPath('mod_jcallback', 'default_email_message');
     $mailer->isHTML(true);
     $mailer->Encoding = 'base64';
     $mailer->setBody($body);
     $mailer->Send();
     // The mail sending errors will be shown in the Joomla Warning Message from JMail object..
 }
Beispiel #8
0
 function sendEmail()
 {
     global $mainframe;
     $mail = JFactory::getMailer();
     $modId = JRequest::getVar('modId');
     $db = JFactory::getDBO();
     $sql = "SELECT params FROM #__modules WHERE id={$modId}";
     $db->setQuery($sql);
     $data = $db->loadResult();
     $params = json_decode($data);
     $success = $params->success;
     $failed = $params->failed;
     $recipient = $params->email;
     $email = JRequest::getVar('email');
     $name = JRequest::getVar('name');
     $subject = JRequest::getVar('subject');
     $message = JRequest::getVar('message');
     $sender = array($email, $name);
     $mail->setSender($sender);
     $mail->addRecipient($recipient);
     $mail->setSubject($subject);
     $mail->isHTML(true);
     $mail->Encoding = 'base64';
     $mail->setBody($message);
     if ($mail->Send()) {
         echo '<p class="sp_qc_success">' . $success . '</p>';
     } else {
         echo '<p class="sp_qc_warn">' . $failed . '</p>';
     }
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 protected function _send()
 {
     $mailer = \JFactory::getMailer();
     if (count($this->_recipient) == 2) {
         $mailer->addRecipient($this->_recipient[0], $this->_recipient[1]);
     }
     if (count($this->_from) == 2) {
         $mailer->setFrom($this->_from[0], $this->_from[1]);
     }
     $mailer->isHtml($this->_htmlMode);
     $mailer->setBody($this->_body);
     $mailer->setSubject($this->_subject);
     foreach ($this->_atachments as $path => $name) {
         $mailer->addAttachment($path, $name);
     }
     foreach ($this->_headers as $headerKey => $headerValue) {
         $mailer->addCustomHeader($headerKey, $headerValue);
     }
     $result = $mailer->send();
     if ($mailer->isError() || !$result) {
         if ($mailer->ErrorInfo) {
             $this->_error($mailer->ErrorInfo);
         }
         return false;
     }
     return $result;
 }
Beispiel #10
0
 public function Process()
 {
     $mail = JFactory::getMailer();
     $this->set_from($mail);
     $this->set_to($mail, "to_address", "addRecipient");
     $this->set_to($mail, "cc_address", "addCC");
     $this->set_to($mail, "bcc_address", "addBCC");
     $mail->setSubject($this->subject());
     $body = $this->body();
     $body .= $this->attachments($mail);
     $body .= PHP_EOL;
     // Info about url
     $body .= JFactory::getConfig()->get("sitename") . " - " . $this->CurrentURL() . PHP_EOL;
     // Info about client
     $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL;
     $body = JMailHelper::cleanBody($body);
     $mail->setBody($body);
     $sent = $this->send($mail);
     if ($sent) {
         // Notify email send success
         $this->MessageBoard->Add($this->Params->get("email_sent_text"), FoxMessageBoard::success);
         $this->Logger->Write("Notification email sent.");
     }
     return $sent;
 }
Beispiel #11
0
    function send_certificate()
    {
        $app = JFactory::getApplication();
        $params = $app->getParams();
        $moodle_url = $params->get('MOODLE_URL');
        $cert_id = JRequest::getVar('cert_id');
        $simple = JRequest::getVar('simple');
        $email = JRequest::getString('mailto', '', 'post');
        $sender = JRequest::getString('sender', '', 'post');
        $from = JRequest::getString('from', '', 'post');
        $user = JFactory::getUser();
        $username = $user->username;
        $subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name);
        $subject = JRequest::getString('subject', $subject_default, 'post');
        if (!$subject) {
            $subject = $subject_default;
        }
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $sender = array($config->get('mailfrom'), $config->get('fromname'));
        $mailer->setSender($sender);
        $mailer->addRecipient($email);
        $body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name);
        $mailer->setSubject($subject);
        $mailer->setBody($body);
        $session = JFactory::getSession();
        $token = md5($session->getId());
        $pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username='******'&token=' . $token);
        $tmp_path = $config->get('tmp_path');
        $filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf';
        file_put_contents($tmp_path . '/' . $filename, $pdf);
        $mailer->addAttachment($tmp_path . '/' . $filename);
        $send = $mailer->Send();
        unlink($tmp_path . '/' . $filename);
        if ($send !== true) {
            JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT'));
        } else {
            ?>
<div style="padding: 10px;">
    <div style="text-align:right">
        <a href="javascript: void window.close()">
            <?php 
            echo JText::_('COM_JOOMDLE_CLOSE_WINDOW');
            ?>
 <?php 
            echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true);
            ?>
</a>
    </div>

    <h2>
        <?php 
            echo JText::_('COM_JOOMDLE_EMAIL_SENT');
            ?>
    </h2>
</div>

<?php 
        }
    }
Beispiel #12
0
 public static function ActNotificaUtente($array)
 {
     $mailer = JFactory::getMailer();
     $config = JFactory::getConfig();
     $sender = array($config->get('mailfrom'), $config->get('fromname'));
     FB::log($sender, " sender ActNotificaUtente ");
     $mailer->setSender($sender);
     $db = JFactory::getDBO();
     $query = "select b.id as id, b.name as nome, b.email as email, a.titolo as titolo\n                from #__gg_contenuti a,  #__users as b,#__gg_notifiche_utente_contenuti_map c\n                where\n                a.tipologia = c.idtipologiacontenuto\n                and c.idutente = b.id\n                and a.id = " . $array['id'];
     FB::log($query, "  ActNotificaUtente ");
     $db->setQuery($query);
     $result = $db->loadAssocList();
     FB::log($result, "  user ActNotificaUtente ");
     //$mailer->addRecipient("*****@*****.**");
     foreach ($result as $sender) {
         FB::log(gglmsHelper::checkContenuto4Utente($sender['id'], $array['id']), "   check user ActNotificaUtente ");
         FB::log($sender, "   sender dentro foreach ActNotificaUtente ");
         if (gglmsHelper::checkContenuto4Utente($sender['id'], $array['id']) != 0) {
             $mailer->addRecipient($sender['email']);
             $body = "Gentile " . $sender['nome'] . "  e' stato pubblicato in EdiAcademy un nuovo contenuto dal titolo: " . $sender['titolo'];
             $mailer->setSubject('Notifica from EdiAcademy');
             $mailer->setBody($body);
             FB::log($mailer, "  mailer ActNotificaUtente ");
             $send = $mailer->Send();
             if ($send !== true) {
                 echo 'Error sending email: ' . $send->__toString();
                 FB::log($send->__toString(), "  error email send ");
             }
             FB::log($send, "  send ActNotificaUtente ");
             //exit();
             $mailer->ClearAllRecipients();
         }
     }
 }
Beispiel #13
0
 function sendMail()
 {
     $user_id = JRequest::getVar('user_id');
     $filePath = JPATH_SITE . "/components/com_flexpaper/output/certificate.pdf";
     $mailer =& JFactory::getMailer();
     $config =& JFactory::getConfig();
     //sender
     $sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
     $mailer->setSender($sender);
     //recipient
     $recipient = array($this->getEmail($user_id));
     $mailer->addRecipient($recipient);
     $body = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
     $mailer->setSubject('Your subject string');
     $mailer->setBody($body);
     // Optional file attached
     $mailer->addAttachment($filePath);
     $send =& $mailer->Send();
     //        echo "<pre>";
     //        print_r($send); die;
     if ($send !== true) {
         echo 'Error sending email: ' . $send->message;
     } else {
         echo 'Mail with certificate was sent on email address ' . $this->getEmail($user_id);
     }
     exit;
 }
Beispiel #14
0
 public function Process()
 {
     $copy_to_submitter = (bool) JRequest::getVar($this->SafeName("copy_to_submitter" . $this->GetId()), NULL, 'POST') || $this->Params->get("copy_to_submitter", NULL) == 1;
     if (!$copy_to_submitter || !isset($this->FieldsBuilder->senderEmail->b2jFieldValue) || empty($this->FieldsBuilder->senderEmail->b2jFieldValue)) {
         $this->B2JSession->Clear('filelist');
         return true;
     }
     $mail = JFactory::getMailer();
     $mail->isHTML(true);
     $this->set_from($mail);
     $this->set_to($mail);
     $mail->setSubject(JMailHelper::cleanSubject($this->Params->get("email_copy_subject", "")));
     $body = $this->Params->get("email_copy_text", "") . PHP_EOL;
     $body .= PHP_EOL;
     if ($this->Params->get("email_copy_summary", NULL)) {
         $body .= $this->body();
         $body .= PHP_EOL;
         $body .= $this->attachments();
         $body .= PHP_EOL;
     }
     $body .= "------" . PHP_EOL . $this->Application->getCfg("sitename") . PHP_EOL;
     $body = JMailHelper::cleanBody($body);
     $mail->setBody($body);
     $this->B2JSession->Clear('filelist');
     $this->send($mail);
     return true;
 }
 public function onPurchase($article_id = null, $user = null, $status = null)
 {
     // Load the article from the database
     $db = JFactory::getDBO();
     $db->setQuery('SELECT * FROM #__content WHERE id = ' . (int) $article_id);
     $article = $db->loadObject();
     if (empty($article)) {
         return false;
     }
     // Parse the text a bit
     $article_text = $article->introtext;
     $article_text = str_replace('{name}', $user->name, $article_text);
     $article_text = str_replace('{email}', $user->email, $article_text);
     // Construct other variables
     $config = JFactory::getConfig();
     $sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
     // Send the mail
     jimport('joomla.mail.mail');
     $mail = JFactory::getMailer();
     $mail->setSender($sender);
     $mail->addRecipient($user->email);
     $mail->addCC($config->getValue('config.mailfrom'));
     $mail->setBody($article_text);
     $mail->setSubject($article->title);
     $mail->isHTML(true);
     $mail->send();
     return true;
 }
 /**
  * Mail function (uses phpMailer)
  *
  * @param string $from From e-mail address
  * @param string $fromname From name
  * @param mixed $recipient Recipient e-mail address(es)
  * @param string $subject E-mail subject
  * @param string $body Message body
  * @param boolean $mode false = plain text, true = HTML
  * @param mixed $cc CC e-mail address(es)
  * @param mixed $bcc BCC e-mail address(es)
  * @param mixed $attachment Attachment file name(s)
  * @param mixed $replyto Reply to email address(es)
  * @param mixed $replytoname Reply to name(s)
  * @return boolean True on success
  */
 function sendMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null)
 {
     // Get a JMail instance
     $mail =& JFactory::getMailer();
     $mail->setSender(array($from, $fromname));
     $mail->setSubject($subject);
     $mail->setBody($body);
     // Are we sending the email as HTML?
     if ($mode) {
         $mail->IsHTML(true);
     }
     $mail->addRecipient($recipient);
     $mail->addCC($cc);
     $mail->addBCC($bcc);
     $mail->addAttachment($attachment);
     // Take care of reply email addresses
     if (is_array($replyto)) {
         $numReplyTo = count($replyto);
         for ($i = 0; $i < $numReplyTo; $i++) {
             $mail->addReplyTo(array($replyto[$i], $replytoname[$i]));
         }
     } elseif (isset($replyto)) {
         $mail->addReplyTo(array($replyto, $replytoname));
     }
     return $mail->Send();
 }
Beispiel #17
0
 public function __construct($app)
 {
     $this->app = $app;
     $this->_mail = JFactory::getMailer();
     $this->application = $this->app->zoo->getApplication();
     $this->_mail->SMTPDebug = 4;
 }
Beispiel #18
0
 function sendOnPageLoad($max = 5)
 {
     $db = EasyBlogHelper::db();
     $config = EasyBlogHelper::getConfig();
     $sendHTML = $config->get('main_mailqueuehtmlformat', 0);
     // Delete existing mails that has already been sent.
     $query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_mailq') . ' WHERE ' . $db->nameQuote('status') . '=' . $db->Quote(1) . ' AND DATEDIFF(NOW(), `created`) >= 7';
     $db->setQuery($query);
     $db->Query();
     $query = 'SELECT `id` FROM `#__easyblog_mailq` WHERE `status` = 0';
     $query .= ' ORDER BY `created` ASC';
     $query .= ' LIMIT ' . $max;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!empty($result)) {
         foreach ($result as $mail) {
             $mailq = EasyBlogHelper::getTable('MailQueue', 'Table');
             $mailq->load($mail->id);
             // update the status to 1 == proccessed
             $mailq->status = 1;
             if ($mailq->store()) {
                 // Send emails out.
                 if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
                     $mail = JFactory::getMailer();
                     $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 } else {
                     JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
                 }
             }
         }
     }
 }
Beispiel #19
0
 /**
  * Utility method to act on a user after it has been saved.
  *
  * This method sends a registration email to new users created in the backend.
  *
  * @param	array		$user		Holds the new user data.
  * @param	boolean		$isnew		True if a new user is stored.
  * @param	boolean		$success	True if user was succesfully stored in the database.
  * @param	string		$msg		Message.
  *
  * @return	void
  * @since	1.6
  */
 public function onUserAfterSave($user, $isnew, $success, $msg)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $mail_to_user = $this->params->get('mail_to_user', 1);
     if ($isnew) {
         // TODO: Suck in the frontend registration emails here as well. Job for a rainy day.
         if ($app->isAdmin()) {
             if ($mail_to_user) {
                 // Load user_joomla plugin language (not done automatically).
                 $lang = JFactory::getLanguage();
                 $lang->load('plg_user_joomla', JPATH_ADMINISTRATOR);
                 // Compute the mail subject.
                 $emailSubject = JText::sprintf('PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', $user['name'], $config->get('sitename'));
                 // Compute the mail body.
                 $emailBody = JText::sprintf('PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', $user['name'], $config->get('sitename'), JUri::root(), $user['username'], $user['password_clear']);
                 // Assemble the email data...the sexy way!
                 $mail = JFactory::getMailer()->setSender(array($config->get('mailfrom'), $config->get('fromname')))->addRecipient($user['email'])->setSubject($emailSubject)->setBody($emailBody);
                 if (!$mail->Send()) {
                     // TODO: Probably should raise a plugin error but this event is not error checked.
                     JError::raiseWarning(500, JText::_('ERROR_SENDING_EMAIL'));
                 }
             }
         }
     } else {
         // Existing user - nothing to do...yet.
     }
 }
Beispiel #20
0
 function sendSubmitEmails($name, $email)
 {
     //Email recipients configured in the component configuration
     $mailer =& JFactory::getMailer();
     //get sender from config
     $config =& JFactory::getConfig();
     $sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
     //retrieve from database
     $model =& $this->getModel('response');
     $email_list = $model->getRecipientList();
     //explode the list and add recipients
     $recip_array = explode(',', $email_list);
     //probably should validate from here, we'll do that later
     $mailer->addRecipient($recip_array);
     $name = JRequest::getVar('name');
     $email = JRequest::getVar('email');
     $organization = JRequest::getVar('organization');
     //finished adding recipients, send message
     $body = $name . " (E-Mail: " . $email . ") from " . $organization . " has submitted a testimonial. \n\n" . "To review and publish this testimonial: \n" . "1. Login to the Joomla administrator back end \n" . "2. Select 'Testimonials' from the Component menu \n" . "3. Either click the icon under the 'Published' column next to the testimonial, " . "or check the testimonials that you want to publish and" . " click the 'Publish' button in the top right toolbar \n\n\n" . "Automatic message generated by Testimonial v0.2 for Joomla 1.5 by Longship Development ";
     $mailer->setSubject('A Testimonial was submitted');
     $mailer->setBody($body);
     $result =& $mailer->Send();
     if ($result !== true) {
         echo '<p>Notification message NOT sent : ' . $result->message . '</p>';
     }
 }
 public function sendMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null)
 {
     $this->initJoomla();
     jimport('joomla.mail.mail');
     $mail = JFactory::getMailer();
     return $mail->sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
 }
Beispiel #22
0
 function submit()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $post = JRequest::get('post');
     // message
     $msg = JText::_('Submit');
     $db =& JFactory::getDBO();
     $id = JRequest::getInt('id');
     $db = JFactory::getDBO();
     $db->setQuery("SELECT * FROM #__profiles WHERE id = " . $id);
     $profile = $db->loadObject();
     $name = JRequest::getVar('name', '', 'post');
     $email = JRequest::getVar('email', '', 'post');
     $telefon = JRequest::getVar('telefon', '', 'post');
     $city = JRequest::getVar('by', '', 'post');
     $subject = JRequest::getVar('subject', 'Jydsk Lasercenter New Contact Email', 'post');
     $body = JRequest::getVar('text', '', 'post');
     $message = "Dear " . $profile->full_name . ",\n\r\n\rYou have a new contact email\n\r\n\rCity: {$city}\nTelefon: {$telefon}\nMessage:\n{$body}\n\r\n\rBest Regards,\n\rWebsite Team";
     jimport('joomla.mail.helper');
     $mail = JFactory::getMailer();
     $mail->addRecipient($profile->email);
     $mail->setSender(array($email, $name));
     $mail->setSubject($subject);
     $mail->setBody($body);
     $sent = $mail->Send();
     echo "<script>window.close();</script>";
 }
Beispiel #23
0
 public function Process()
 {
     $copy_to_submitter = (bool) JRequest::getVar($this->SafeName("copy_to_submitter" . $this->GetId()), NULL, 'POST') || $this->Params->get("copy_to_submitter", NULL) == 1;
     // always send a copy parameter
     if (!$copy_to_submitter || !isset($this->FieldsBuilder->Fields['sender1']) || empty($this->FieldsBuilder->Fields['sender1']['Value'])) {
         $this->FSession->Clear('filelist');
         //JLog::add("Copy email for the submitter skipped.", JLog::INFO, get_class($this));
         return true;
     }
     $mail = JFactory::getMailer();
     $this->set_from($mail);
     $this->set_to($mail);
     $mail->setSubject(JMailHelper::cleanSubject($this->Params->get("email_copy_subject", "")));
     // Body
     $body = $this->Params->get("email_copy_text", "") . PHP_EOL;
     // a blank line
     $body .= PHP_EOL;
     if ($this->Params->get("email_copy_summary", NULL)) {
         $body .= $this->body();
         $body .= $this->attachments();
         $body .= PHP_EOL;
     }
     // A null body will raise a mail error, so always add at least a signature.
     $body .= "------" . PHP_EOL . $this->Application->getCfg("sitename") . PHP_EOL;
     $body = JMailHelper::cleanBody($body);
     $mail->setBody($body);
     // Clear file list for the next submission of the same users
     $this->FSession->Clear('filelist');
     $this->send($mail);
     return true;
 }
 private function sendNotificationOnUpdateRank($userinfo, $result)
 {
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     $lang->load('com_alphauserpoints', JPATH_SITE);
     jimport('joomla.mail.helper');
     require_once JPATH_ROOT . '/components/com_alphauserpoints/helper.php';
     // get params definitions
     $params = JComponentHelper::getParams('com_alphauserpoints');
     $jsNotification = $params->get('jsNotification', 0);
     $jsNotificationAdmin = $params->get('fromIdUddeim', 0);
     $SiteName = $app->getCfg('sitename');
     $MailFrom = $app->getCfg('mailfrom');
     $FromName = $app->getCfg('fromname');
     $sef = $app->getCfg('sef');
     $email = $userinfo->email;
     $subject = $result->emailsubject;
     $body = $result->emailbody;
     $formatMail = $result->emailformat;
     $bcc2admin = $result->bcc2admin;
     $subject = str_replace('{username}', $userinfo->username, $subject);
     $subject = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $subject);
     $body = str_replace('{username}', $userinfo->username, $body);
     $body = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $body);
     $subject = JMailHelper::cleanSubject($subject);
     if (!$jsNotification) {
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($MailFrom, $FromName));
         $mailer->setSubject($subject);
         $mailer->isHTML((bool) $formatMail);
         $mailer->CharSet = "utf-8";
         $mailer->setBody($body);
         $mailer->addRecipient($email);
         if ($bcc2admin) {
             // get all users allowed to receive e-mail system
             $query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
             $db->setQuery($query);
             $rowsAdmins = $db->loadObjectList();
             foreach ($rowsAdmins as $rowsAdmin) {
                 $mailer->addBCC($rowsAdmin->email);
             }
         }
         $send = $mailer->Send();
     } else {
         require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
         $params = new CParameter('');
         CNotificationLibrary::add('system_messaging', $jsNotificationAdmin, $userinfo->id, $subject, $body, '', $params);
         if ($bcc2admin) {
             // get all users allowed to receive e-mail system
             $query = "SELECT id" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
             $db->setQuery($query);
             $rowsAdmins = $db->loadObjectList();
             foreach ($rowsAdmins as $rowsAdmin) {
                 $mailer->addBCC($rowsAdmin->id);
                 CNotificationLibrary::add('system_messaging', $userinfo->id, $rowsAdmin->id, $subject, $body, '', $params);
             }
         }
     }
 }
Beispiel #25
0
 /**
  * AutotweetMailChannel
  *
  * @param   object  &$channel  Param
  */
 public function __construct(&$channel)
 {
     parent::__construct($channel);
     $this->mailer = JFactory::getMailer();
     $config = JFactory::getConfig();
     $sender = array($config->get($this->get('mail_sender_email')), $config->get($this->get('mail_sender_name')));
     $this->mailer->setSender($sender);
 }
Beispiel #26
0
 /**
  * Sends mail to administrator for approval of a user submission
  *
  * @param   string  $adminName   Name of administrator
  * @param   string  $adminEmail  Email address of administrator
  * @param   string  $email       [NOT USED]
  * @param   string  $type        Type of item to approve
  * @param   string  $title       Title of item to approve
  * @param   string  $author      Author of item to approve
  * @param   string  $url         url
  *
  * @return  boolean  True on success
  *
  * @deprecated  12.1
  * @see     JMail::sendAdminMail()
  * @since   11.1
  */
 public static function sendAdminMail($adminName, $adminEmail, $email, $type, $title, $author, $url = null)
 {
     // Deprecation warning.
     JLog::add('JUtility::sendAdminMail() is deprecated.', JLog::WARNING, 'deprecated');
     // Get a JMail instance
     $mail = JFactory::getMailer();
     return $mail->sendAdminMail($adminName, $adminEmail, $email, $type, $title, $author, $url);
 }
Beispiel #27
0
	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save()
	{
		// Check for request forgeries.
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Initialise variables.
		$app		= JFactory::getApplication();
		$lang		= JFactory::getLanguage();
		$model		= $this->getModel();
		$table		= $model->getTable();

 		$uri  = JFactory::getURI();
		$mail = JFactory::getMailer();
		$db   = JFactory::getDBO();
		
		$data = JRequest::get('post');

		$decline		= $data['jform']['hstatus'];
		$name			= $data['jform']['hname'];
		$comment		= $data['jform']['hcomment'];
		$usermail		= $data['jform']['hmail'];
		$decline_mail	= $data['jform']['declinemail'];

		//ACL stuff
		$canDo		= HelpdeskHelper::getActions();
		$canAdd 	= $canDo->get('core.create');
		$canEdit	= $canDo->get('core.edit');

		//get mail addresses of all super administrators
		$query = 'SELECT email' .
				' FROM #__users' .
				' WHERE LOWER( usertype ) = "super administrator" AND sendEmail = 1';
		$db->setQuery( $query );
		$admins = $db->loadResultArray();

		$msg = '';
		if ($model->save($data['jform'])) {
        	$msg .= JText::_( 'Entry Saved' );
  			$type = 'message';

  			if (($decline == -1) && ($decline_mail==1)) {
				$body = JText::_('COM_HELPDESK_ENTRY_DECLINED_MAIL_BODY'). $comment;
				$mail->IsHTML(true);
				$mail->setSubject(JText::_('COM_HELPDESK_ENTRY_DECLINED_MAIL_SUBJECT'));
				$mail->setBody( $body );
				$mail->addRecipient( $usermail );
				$mail->addBCC( $admins );
				$mail->Send();
				$msg .= ".  ".JText::_('COM_HELPDESK_DECLINE_MAIL_SENT');
  				$type = 'message';
			}
	    } else {
	        $msg = JText::_('COM_HELPDESK_ERROR_SAVING_ENTRY');
	        $type = 'error';
	    }

		$this->setRedirect( 'index.php?option=com_helpdesk', $msg, $type);
	}
Beispiel #28
0
	public function send( $max = 5 )
	{
		$konfig		= Komento::getKonfig();

		if( $konfig->get( 'disable_mailq' ) )
		{
			return false;
		}

		$db			= Komento::getDBO();
		$config		= Komento::getConfig();

		$sql = Komento::getSql();

		$sql->select( '#__komento_mailq' )
			->column( 'id' )
			->where( 'status', 0 )
			->order( 'created' )
			->limit( $max );

		$result = $sql->loadObjectList();

		if(! empty($result))
		{
			foreach($result as $mail)
			{
				$mailq	= Komento::getTable('mailq');
				$mailq->load($mail->id);

				$sendHTML = $mailq->type == 'html' ? 1 : 0;

				$state = 0;

				if( empty( $mailq->recipient ) )
				{
					$state = 1;
				}

				//send emails.
				if( Komento::isJoomla15() )
				{
					$state = JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}
				else
				{
					$mail = JFactory::getMailer();
					$state = $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}

				if( $state )
				{
					// update the status to 1 == proccessed
					$mailq->status  = 1;
					$mailq->store();
				}
			}
		}
	}
Beispiel #29
0
 function envoi_mail($chaine, $to, $sujet, $from)
 {
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
     $uri = $_SERVER['REQUEST_URI'];
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     $remote_addr = $_SERVER['REMOTE_ADDR'];
     $host = $_SERVER["HTTP_HOST"];
     $envoyer = "oui";
     foreach ($chaine as $value) {
         switch ($value['type']) {
             case 1:
                 //we look for the keyword in the uri
                 if (strpos($uri, $value['chaine']) !== FALSE) {
                     $envoyer = "non";
                 }
                 break;
             case 2:
                 //we look for the keyword in the referrer
                 if (strpos($referer, $value['chaine']) !== FALSE) {
                     $envoyer = "non";
                 }
                 break;
             case 3:
                 //we look for the keyword in the user_agent
                 if (strpos($user_agent, $value['chaine']) !== FALSE) {
                     $envoyer = "non";
                 }
                 break;
             default:
                 //by default we send mail
         }
     }
     if ($envoyer == "oui") {
         $mailer =& JFactory::getMailer();
         $mailer->addRecipient($to);
         $mailer->setSubject($sujet);
         $referer = $referer == "" ? JTEXT::_("COM_ERROR404_PAGE_INCONNUE") : "<a href='{$referer}'>{$referer}</a>";
         $message = JTEXT::_("COM_ERROR404_INTRO_MAIL") . " " . $host . " :<br /><a href=\"http://{$host}{$uri}\">{$host}{$uri}</a><br /><br />";
         $message .= JTEXT::_("COM_ERROR404_DETAILS_UTILISATEUR") . " :";
         $message .= "<br />user_agent :<br /> " . $user_agent . "<br />Remote adress :<br />" . $remote_addr . "<br /><br />";
         $message .= JTEXT::_("COM_ERROR404_PAGE_ERREUR") . " : <br />" . $referer . "<br />";
         $message .= JTEXT::_("COM_ERROR404_FIN_MESSAGE");
         //$headers  = "MIME-Version: 1.0\r\n";
         //$headers .= "content-type: text/html; charset=iso-8859-1\r\n";
         $mailer->isHTML(true);
         $mailer->setBody($message);
         if ($from != "") {
             $mailer->setSender($from);
         }
         $test =& $mailer->Send();
         //$test=mail($to,$sujet,$message,$headers);
         $texte = $test == TRUE ? JTEXT::_("COM_ERROR404_MESSAGE_ENVOYE") : JTEXT::_("COM_ERROR404_PB_MAIL_PAS_ENVOYE");
     } else {
         $texte = JTEXT::_("COM_ERROR404_ERREUR_PAS_MAIL");
     }
     return $texte;
 }
 static function dispatchEmail($from, $fromname, $to_email, $subject, $body, $attachment = null)
 {
     if (!version_compare(JVERSION, '1.6.0', 'ge')) {
         $sendresult =& JUtility::sendMail($from, $fromname, $to_email, $subject, $body, null, null, null, $attachment);
     } else {
         $sendresult =& JFactory::getMailer()->sendMail($from, $fromname, $to_email, $subject, $body, null, null, null, $attachment);
     }
     return $sendresult;
 }