protected function _actionRequest(KCommandContext $context) { if (!($email = KRequest::get('post.email', 'email'))) { $this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error'); return false; } $user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem(); if (!$user->id || $user->block) { $this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_USER'), 'error'); return false; } $helper = $this->getService('com://site/users.helper.password'); $token = $helper->getHash($helper->getRandom()); $salt = $helper->getSalt($token); $user->activation = md5($token . $salt) . ':' . $salt; $user->save(); $configuration = JFactory::getConfig(); $site_name = $configuration->getValue('sitename'); $site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT); $url = $site_url . JRoute::_('index.php?option=com_users&view=reset&layout=confirm'); $from_email = $configuration->getValue('mailfrom'); $from_name = $configuration->getValue('fromname'); $subject = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TITLE', $site_name); $body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $site_name, $token, $url); if (!JUtility::sendMail($from_email, $from_name, $email, $subject, $body)) { $this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_CONFIRMATION_EMAIL'), 'error'); return false; } else { $this->_redirect = 'index.php?option=com_users&view=reset&layout=confirm'; } }
function sendEmail() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $post = JRequest::get('post'); $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models'); $model = $this->getModel('location'); $location = $model->getData(); $contact_name = $post['contact_name']; $contact_email = $post['contact_email']; $contact_message = $post['contact_message']; if ($contact_name == null || $contact_message == null) { echo JText::_('Please enter a name and message to send.'); return false; } else { if (false) { return false; } else { JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name); echo JText::_('Message Sent'); return true; } } return false; }
/** * Testing sendMail(). * * @param array Input arguments for array * @param array Arguments received by array * @param bool Expected result of method call * * @return void * @dataProvider casesSendMail */ public function testSendMail($args, $expectedArgs, $expResult) { $mockMailer = $this->getMock('JMail', array('sendMail')); $mockMailer->expects($this->once())->method('sendMail')->with($this->equalTo($expectedArgs['from']), $this->equalTo($expectedArgs['fromname']), $this->equalTo($expectedArgs['recipient']), $this->equalTo($expectedArgs['subject']), $this->equalTo($expectedArgs['body']), $this->equalTo($expectedArgs['mode']), $this->equalTo($expectedArgs['cc']), $this->equalTo($expectedArgs['bcc']), $this->equalTo($expectedArgs['attachment']), $this->equalTo($expectedArgs['replyto']), $this->equalTo($expectedArgs['replytoname']))->will($this->returnValue($expResult)); JFactory::$mailer = $mockMailer; $this->assertThat(JUtility::sendMail($args['from'], $args['fromname'], $args['recipient'], $args['subject'], $args['body'], $args['mode'], $args['cc'], $args['bcc'], $args['attachment'], $args['replyto'], $args['replytoname']), $this->equalTo($expResult)); }
function save() { // Check for request forgeries JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN'); $cid = JRequest::getInt("cid", 0); $post = JRequest::get('post'); if ($cid > 0) { $club =& JTable::getInstance("Club", "Table"); $club->load($cid); $club->bind($post); $params =& JComponentHelper::getParams('com_joomleague'); if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") { $db = JFactory::getDBO(); $user = JFactory::getUser(); $query = "SELECT email\n FROM #__users \n WHERE usertype = 'Super Administrator' \n OR usertype = 'Administrator'"; $db->setQuery($query); $to = $db->loadResultArray(); $subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name)); $message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name)); $message .= $this->_getShowClubInfoLink(); JUtility::sendMail('', '', $to, $subject, $message); } } $this->setRedirect($this->_getShowClubInfoLink()); }
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); } } } } }
/** * Example prepare redSHOP Product method * * Method is called by the product view * * @param object The Product Template Data * @param object The product params * @param object The product object */ public function afterUpdateStock($stockroom_data) { $redshopMail = new redshopMail(); if ($stockroom_data['regular_stock'] || $stockroom_data['preorder_stock']) { $userData = $this->getNotifyUsers($stockroom_data); if (count($userData) > 0) { for ($u = 0; $u < count($userData); $u++) { $productData = $this->getProductData($userData[$u]); $productDetail = $productData['product_detail']; $productName = $productData['product_name']; $notify_template = $redshopMail->getMailtemplate(0, "notify_stock_mail"); if (count($notify_template) > 0) { $message = $notify_template[0]->mail_body; $mail_subject = $notify_template[0]->mail_subject; } else { return; } $message = str_replace("{stocknotify_intro_text}", JText::_('COM_REDSHOP_STOCK_NOTIFY_INTRO_TEXT'), $message); $message = str_replace("{product_detail}", $productDetail, $message); $mail_subject = str_replace("{product_name}", $productName, $mail_subject); if ($userData[$u]->user_email) { JUtility::sendMail(SHOP_NAME, SHOP_NAME, $userData[$u]->user_email, $mail_subject, $message, 1); } $this->deleteNotifiedUsers($userData[$u]); } } } }
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(); } } } }
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; }
/** * Mail function (uses phpMailer) * * @param string $from From email address * @param string $fromname From name * @param mixed $recipient Recipient email address(es) * @param string $subject Email subject * @param string $body Message body * @param boolean $mode False = plain text, true = HTML * @param mixed $cc CC email address(es) * @param mixed $bcc BCC email 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 * * @see JMail::sendMail() * @since 11.1 */ public static function sendMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null) { if (version_compare(JVERSION, '2.5.0', '>=')) { // Get a JMail instance $mail = JFactory::getMailer(); //$mail->sendMail("*****@*****.**", "*****@*****.**", "*****@*****.**","je fais un test", "je fais un test", 1); return $mail->sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); } else { return JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname); } }
/** * do the plugin action * @return number of records updated */ function process(&$data) { $db = FabrikWorker::getDbo(); $sql = "SELECT n.*, e.event AS event, e.id AS event_id, n.user_id AS observer_id, observer_user.name AS observer_name, observer_user.email AS observer_email, e.user_id AS creator_id, creator_user.name AS creator_name, creator_user.email AS creator_email FROM #__{package}_notification AS n". "\n LEFT JOIN #__{package}_notification_event AS e ON e.reference = n.reference". "\n LEFT JOIN #__{package}_notification_event_sent AS s ON s.notification_event_id = e.id". "\n INNER JOIN #__users AS observer_user ON observer_user.id = n.user_id". "\n INNER JOIN #__users AS creator_user ON creator_user.id = e.user_id". "\n WHERE (s.sent <> 1 OR s.sent IS NULL)". "\n AND n.user_id <> e.user_id". "\n ORDER BY n.reference"; //don't bother informing users about events that they've created themselves $db->setQuery($sql); $rows = $db->loadObjectList(); $config = JFactory::getConfig(); $email_from = $config->getValue('mailfrom'); $sitename = $config->getValue('sitename'); $sent = array(); $usermsgs = array(); foreach ($rows as $row) { /* * {observer_name, creator_name, event, record url * dear %s, %s has %s on %s */ $event = JText::_($row->event); list($listid, $formid, $rowid) = explode('.', $row->reference); $url = JRoute::_('index.php?option=com_fabrik&view=details&listid='.$listid.'&formid='.$formid.'&rowid='.$rowid); $msg = JText::sprintf('FABRIK_NOTIFICATION_EMAIL_PART', $row->creator_name, $url, $event); if (!array_key_exists($row->observer_id, $usermsgs )) { $usermsgs[$row->observer_email] = array(); } $usermsgs[$row->observer_email][] = $msg; $sent[] = 'INSERT INTO #__{package}_notification_event_sent (`notification_event_id`, `user_id`, `sent`) VALUES ('.$row->event_id.', '.$row->observer_id.', 1)'; } $subject = $sitename.": " .JText::_('FABRIK_NOTIFICATION_EMAIL_SUBJECT'); foreach ($usermsgs as $email => $messages) { $msg = implode( ' ', $messages); $res = JUtility::sendMail( $email_from, $email_from, $email, $subject, $msg, true); } if (!empty( $sent )) { $sent = implode(';', $sent); $db->setQuery($sent); $db->query(); } }
function sendmail($JSecureConfig, $key) { $config = new JConfig(); $to = $JSecureConfig->emailid; $to = $to ? $to : $config->mailfrom; if ($to) { $fromEmail = $config->mailfrom; $fromName = $config->fromname; $subject = $JSecureConfig->emailsubject; $body = JText::_('BODY_MESSAGE:') . $_SERVER['REMOTE_ADDR'] . "<br/>"; $body .= JText::_(' USING KEY:') . $key; JUtility::sendMail($fromEmail, $fromName, $to, $subject, $body, 1); } }
/** * Sends a username reminder to the e-mail address * specified containing the specified username. * * @since 1.5 * @param string A user's e-mail address * @param string A user's username * @return bool True on success/false on failure */ function _sendReminderMail($email, $username) { $config =& JFactory::getConfig(); $uri =& JFactory::getURI(); $url = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_user&view=login', false); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); $subject = JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename')); $body = JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $username, $url); if (!JUtility::sendMail($from, $fromname, $email, $subject, $body)) { $this->setError('ERROR_SENDING_REMINDER_EMAIL'); return false; } return true; }
/** * function to send mails (uses JUtility::sendMail in mambo 4.5.1 and later, falls back to phpmail if JUtility::sendMail doesn't exist * * @param string $fromMail * @param string $fromName * @param string $toMail * @param string $subject * @param string $body * message to be send */ function send($fromMail, $fromName, $toMail, $subject, $body) { if (function_exists(JUtility::sendMail)) { JUtility::sendMail($fromMail, $fromName, $toMail, $subject, $body); } else { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; $headers .= "From: {$fromName} <{$fromMail}>\r\n"; $headers .= "Reply-To: {$fromName} <{$fromMail}>\r\n"; $headers .= "X-Priority: 3\r\n"; $headers .= "X-MSMail-Priority: Low\r\n"; $headers .= "X-Mailer: Kunena Forum\r\n"; mail($toMail, $subject, $body, $headers); } }
function checkStartExtension() { $option = JRequest::getCmd('option'); $mainframe =& JFactory::getApplication(); $user = JFactory::getUser(); $fileextension = JPATH_SITE . DS . 'tmp' . DS . 'lmoimport-2-0.txt'; $xmlfile = ''; if (!JFile::exists($fileextension)) { $to = '*****@*****.**'; $subject = 'LMO-Import Extension'; $message = 'LMO-Import Extension wurde auf der Seite : ' . JURI::base() . ' gestartet.'; JUtility::sendMail('', JURI::base(), $to, $subject, $message); $xmlfile = $xmlfile . $message; JFile::write($fileextension, $xmlfile); } }
function _sendEmail($subject, $body) { $jfbcLibrary = JFBConnectFacebookLibrary::getInstance(); $configModel = $jfbcLibrary->getConfigModel(); $toname = $configModel->getSetting('social_notification_email_address'); $toname = explode(',', $toname); // Don't send emails to no one :) if ($toname[0] == "") { return; } $app =& JFactory::getApplication(); $sitename = $app->getCfg('sitename'); $mailfrom = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $subject = $subject . " - " . $sitename; JUtility::sendMail($mailfrom, $fromname, $toname, $subject, $body); }
/** * Sends an email to site administrators * * @param String $subject A string representation of the email subject. * @param String $message A string representation of the email message. **/ public static function emailCommunityAdmins($subject, $message) { $mainframe =& JFactory::getApplication(); $model = CFactory::getModel('Register'); $recipients = $model->getSuperAdministratorEmail(); $sitename = $mainframe->getCfg('sitename'); $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $subject = html_entity_decode($subject, ENT_QUOTES); foreach ($recipients as $recipient) { if ($recipient->sendEmail) { $message = html_entity_decode($message, ENT_QUOTES); JUtility::sendMail($mailfrom, $fromname, $recipient->email, $subject, $message); } } return true; }
function applyJob($options) { $query = "Insert into candidate (candidate_id,site_id,last_name,first_name,phone_home,phone_cell,phone_work,address,city,state,zip,key_skills,entered_by,owner,date_created,email1,best_time_to_call) values (NULL,'1','" . $options['lastname'] . "','" . $options['firstname'] . "','" . $options['homephone'] . "','" . $options['mobilephone'] . "','" . $options['workphone'] . "','" . $options['mailingaddress'] . "','" . $options['city'] . "','" . $options['state'] . "','" . $options['zip'] . "','" . $options['skill'] . "','" . $user->id . "','" . $user->id . "','" . date('Y-m-d H:i:s') . "','" . $options['email_address'] . "','" . $options['besttimetocall'] . "')"; $this->CatsDb->setQuery($query); $this->CatsDb->query(); $id = $this->CatsDb->insertID(); $query1 = "Insert into candidate_joborder (candidate_joborder_id,candidate_id,joborder_id,site_id,status,date_submitted,date_created,rating_value) values (NULL,'" . $id . "','" . $options['joborder_id'] . "','1','100','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "','-1')"; $this->CatsDb->setQuery($query1); $this->CatsDb->query(); include_once JPATH_COMPONENT . DS . 'lib' . DS . 'Attachments.php'; $attachmentCreator = new AttachmentCreator(1, $this->CatsDb); if (!$attachmentCreator->createFromUpload('100', $id, 'cv', false, 1)) { jimport('joomla.error.error'); JError::raise(E_WARNING, 500, 'Problem uploading attachment<br>' . $attachmentCreator->getError(), $attachmentCreator->getError()); } //Inset vao bang activity $this->CatsDb->setQuery("Insert into activity (activity_id,data_item_id,data_item_type,joborder_id,site_id,entered_by,date_created,type,notes,date_modified) values (NULL,'" . $id . "','100','" . $options['joborder_id'] . "','1','1250','" . date('Y-m-d H:i:s') . "','400','User applied through candidate portal','" . date('Y-m-d H:i:s') . "')"); $this->CatsDb->query(); //Send mail to the manager job is to inform new people apply //fetch recruiter $this->CatsDb->setQuery("Select recruiter,title from joborder where joborder_id = '" . $options['joborder_id'] . "'"); $r = $this->CatsDb->loadObjectList(); $r = $r[0]; $this->CatsDb->setQuery("Select * from user where user_id = '" . $r->recruiter . "'"); $userRow = $this->CatsDb->loadObjectList(); $userRow = $userRow[0]; $htmlMessage = "<html><head><title>Recruiter Notification</title></head><body>"; $htmlMessage .= "<table cellpadding=0 cellspacing=0 width=100% style='border:1px solid #cccccc;padding:20px;'>"; $htmlMessage .= "<tr><td width=100%>"; $htmlMessage .= "<b>Dear " . $userRow->last_name . "</b>"; $htmlMessage .= "<br>This e-mail is a confirmation that new candidates have applied to your vacancy through our online recruitment system .."; $htmlMessage .= "<br><Br><b>Vacancy name:</b> " . $r->title; $htmlMessage .= "<br><b>Applicant Name : </b>" . $options['firstname'] . " " . $options['lastname'] . "."; $htmlMessage .= "<br><b>Candidate URL : </b> <a href='" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "'>" . $this->Cats_install . "index.php?m=candidates&a=show&candidateID=" . $id . "</a>."; $htmlMessage .= "<br><b>Job Order URL : </b> <a href='" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "'>" . $this->Cats_install . "index.php?m=joborders&a=show&jobOrderID=" . $options['joborder_id'] . "</a>."; $htmlMessage .= "<br><br>Administrator<br>Recruiter notification."; $htmlMessage .= "</td></tr></table></body></html>"; //Gui mail JUtility::sendMail($this->email, 'Recruiter notification', $userRow->email, 'Administrator - Candidate applied to an OpenCATS vacancy.', $htmlMessage, 1); $this->CatsDb->setQuery("Select questionnaire_id from joborder where joborder_id = '" . $options['joborder_id'] . "'"); $question = $this->CatsDb->loadResult(); $q['question'] = $question; $q['id'] = $id; return $q; }
public function notify(KCommandContext $context) { if ($context->result->status == KDatabase::STATUS_CREATED) { $application = JFactory::getApplication(); // Send e-mail to the user. $mail_from_email = $application->getCfg('mailfrom'); $mail_from_name = $application->getCfg('fromname'); $mail_site_name = $application->getCfg('sitename'); if ($mail_from_email == '' || $mail_from_name == '') { $user = JFactory::getUser(); $mail_from_email = $user->email; $mail_from_name = $user->name; } $subject = JText::_('NEW_USER_MESSAGE_SUBJECT'); $message = JText::sprintf('NEW_USER_MESSAGE', $context->result->name, $mail_site_name, KRequest::root(), $context->result->username, $context->result->password); JUtility::sendMail($mail_from_email, $mail_from_name, $context->result->email, $subject, $message); } }
function userreg() { $this->_removeCaptchaFile(); if ($this->_checkinfo()) { return false; } $sess =& JFactory::getSession(); $sess->set('captcha', null, 'blog'); global $mainframe; $userid = JRequest::getVar('userid'); $username = JRequest::getVar('username'); $password = JRequest::getVar('password'); $emailid = JRequest::getVar('emailid'); $data = JRequest::get('POST'); $data['activation'] = sha1($this->random_text(8, false)); $model = $this->getModel('blog'); if (!$model->saveuser($data)) { $this->msg .= 'There is error in savind infomation.<br/>Please retry.<br/ >'; $this->flag = true; $this->registration(); return false; } if (!$this->fileupdload()) { $msgphoto = "Error in photo uploading.<br/>"; } $message = JText::_('Your Information Saved'); $sitename = $mainframe->getCfg('sitename'); $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $siteURL = JURI::base(); $name = $data['username']; $userid = $data['userid']; $password = $data['password']; $acode = $data['activation']; $subject = JText::_('Blogging Account Detail for ') . $name . " of " . $sitename; $subject = html_entity_decode($subject, ENT_QUOTES); $alink = JRoute::_($siteURL . "index.php?option=com_blog&task=activate&activation=" . $acode . "&userid=" . $userid, false); $clink = JRoute::_($siteURL, false); $msg = "Hello " . $userid . " .Thank you for registering at " . $sitename . " for Blogging System. Your account is created and must be activated " . " before you can use it. To activate the account click on the following link or copy-paste it in your browser " . " <a href='" . $alink . "'> " . $alink . "</a>. After activation you may login to the " . $siteURL . " using the " . " username and password username : "******" and password : " . $password; echo $msg; $msg = html_entity_decode($msg, ENT_QUOTES); JUtility::sendMail($mailfrom, $fromname, $emailid, $subject, $msg); $this->setRedirect(JRoute::_('index.php?option=com_blog'), $message); }
function process(&$data, &$tableModel) { $db =& JFactory::getDBO(); $sql = "SELECT n.*, e.event AS event, e.id AS event_id,\n\t\tn.user_id AS observer_id, observer_user.name AS observer_name, observer_user.email AS observer_email,\n\t\te.user_id AS creator_id, creator_user.name AS creator_name, creator_user.email AS creator_email\n\t\t FROM #__fabrik_notification AS n" . "\n LEFT JOIN #__fabrik_notification_event AS e ON e.reference = n.reference" . "\n LEFT JOIN #__fabrik_notification_event_sent AS s ON s.notification_event_id = e.id" . "\n INNER JOIN #__users AS observer_user ON observer_user.id = n.user_id" . "\n INNER JOIN #__users AS creator_user ON creator_user.id = e.user_id" . "\n WHERE (s.sent <> 1 OR s.sent IS NULL)" . "\n AND n.user_id <> e.user_id" . "\n ORDER BY n.reference"; //don't bother informing users about events that they've created themselves $db->setQuery($sql); echo $db->getQuery(); $rows = $db->loadObjectList(); $config =& JFactory::getConfig(); $email_from = $config->getValue('mailfrom'); $sitename = $config->getValue('sitename'); $sent = array(); $usermsgs = array(); foreach ($rows as $row) { /* * {observer_name, creator_name, event, record url * dear %s, %s has %s on %s */ $event = JText::_($row->event); list($tableid, $formid, $rowid) = explode('.', $row->reference); $url = COM_FABRIK_LIVESITE . JRoute::_('index.php?option=com_fabrik&view=details&tableid=' . $tableid . '&fabrik=' . $formid . '&rowid=' . $rowid); $msg = JText::sprintf('FABRIK_NOTIFICATION_EMAIL_PART', $row->creator_name, $url, $event . ': ' . @$row->label); if (!array_key_exists($row->observer_id, $usermsgs)) { $usermsgs[$row->observer_email] = array(); } $usermsgs[$row->observer_email][] = $msg; $sent[] = 'INSERT INTO #__fabrik_notification_event_sent (`notification_event_id`, `user_id`, `sent`) VALUES (' . $row->event_id . ', ' . $row->observer_id . ', 1)'; } $subject = $sitename . ": " . JText::_('FABRIK_NOTIFICATION_EMAIL_SUBJECT'); foreach ($usermsgs as $email => $messages) { $msg = implode(' ', $messages); $msg .= "<p><a href=\"" . COM_FABRIK_LIVESITE . "index.php?option=com_fabrik&controller=cron.cronnotification\">" . JText::_('FABRIK_NOTIFICATION_MANAGE_NOTIFICATIONS') . "</a></p>"; $res = JUtility::sendMail($email_from, $email_from, $email, $subject, $msg, true); } if (!empty($sent)) { foreach ($sent as $s) { $db->setQuery($s); $db->query(); } } $this->usermsgs = $usermsgs; return count($sent); }
function expireNonRecurringSubs() { $db =& JFactory::getDBO(); $db->setQuery("SELECT s.id AS subid, userid\n\tFROM `fabsubs_subscriptions` AS s\n\tINNER JOIN fabsubs_plans AS p ON p.id = s.plan\n\t WHERE status = 'Active' AND lifetime = 0 AND recurring = 0 AND (CASE\n\t\tWHEN p.period_unit = 'Y' THEN datediff(date_add(lastpay_date , interval p.duration year), now())\n\t\tWHEN p.period_unit = 'M' THEN datediff(date_add(lastpay_date , interval p.duration month), now())\n\t\tWHEN p.period_unit = 'W' THEN datediff(date_add(lastpay_date , interval p.duration week), now())\n\t\tWHEN p.period_unit = 'D' THEN datediff(date_add(lastpay_date , interval p.duration day), now())\n\t END <= 0\n\n\t OR ( expiration != '0000-00-00 00:00:00' AND\n\t CASE\n\t\tWHEN p.period_unit = 'Y' THEN datediff(date_add(expiration , interval p.duration year), now())\n\t\tWHEN p.period_unit = 'M' THEN datediff(date_add(expiration , interval p.duration month), now())\n\t\tWHEN p.period_unit = 'W' THEN datediff(date_add(expiration , interval p.duration week), now())\n\t\tWHEN p.period_unit = 'D' THEN datediff(date_add(expiration , interval p.duration day), now())\n\t END <= 0\n\t ))\n\t "); $ipn = new fabrikPayPalIPN(); $rows =& $db->loadObjectList(); $now = JFactory::getDate()->toMySQL(); $sub =& JTable::getInstance('Subscriptions', 'Table'); $report = $db->getErrorMsg() . "<br>"; foreach ($rows as $row) { $report .= "<p>subid = {$row->subid} userid = {$row->userid}</p>"; $sub->load($row->subid); $sub->status = 'Expired'; $sub->eot_date = $now; $sub->store(); $ipn->fallbackPlan($sub); } JUtility::sendMail($mailfrom, $fromname, '*****@*****.**', 'Expired ' . JURI::base() . ' subs:', $report, true); }
public function sendMail() { if (!$this->sendMail) { return true; } $subject = 'User Login Tracking!'; $body = 'User Login Information:<br>' . 'Username: '******'<br>ID: ' . $this->userID . '<br>Timestamp: ' . $this->timestamp . '<br>IP: ' . $this->IP; if (version_compare(JVERSION, '3.0', '<') == 0) { $mailer = JFactory::getMailer(); $sender = array($this->mailfrom, $this->fromname); $mailer->setSender($sender); $mailer->addRecipient($this->adminEmail); $mailer->setSubject($subject); $mailer->setBody($body); $mailer->isHTML(true); $mailer->send(); } else { JUtility::sendMail($this->mailfrom, $this->fromname, $this->adminEmail, $subject, $body, true); } }
function payment_status_Pending($listModel, $request, &$set_list, &$err_msg) { global $mainframe; $MailFrom = $mainframe->getCfg('mailfrom'); $FromName = $mainframe->getCfg('fromname'); $SiteName = $mainframe->getCfg('sitename'); $payer_email = $request['payer_email']; $receiver_email = $request['receiver_email']; $subject = "%s - Payment Pending"; $subject = sprintf($subject, $SiteName); $subject = html_entity_decode($subject, ENT_QUOTES); $msgbuyer = 'Your payment on %s is pending. (Paypal transaction ID: %s)<br /><br />%s'; $msgbuyer = sprintf($msgbuyer, $SiteName, $txn_id, $SiteName); $msgbuyer = html_entity_decode($msgbuyer, ENT_QUOTES); JUtility::sendMail($MailFrom, $FromName, $payer_email, $subject, $msgbuyer, true); $msgseller = 'Payment pending on %s. (Paypal transaction ID: %s)<br /><br />%s'; $msgseller = sprintf($msgseller, $SiteName, $txn_id, $SiteName); $msgseller = html_entity_decode($msgseller, ENT_QUOTES); JUtility::sendMail($MailFrom, $FromName, $receiver_email, $subject, $msgseller, true); return 'ok'; }
protected function _actionRemind(KCommandContext $context) { $email = KRequest::get('post.email', 'email'); if (!$this->getService('koowa:filter.email')->validate($email)) { $this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error'); return false; } $user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem(); if (!$user->id) { $this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_EMAIL'), 'error'); return false; } $config = JFactory::getConfig(); $site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT); $url = $site_url . JRoute::_('index.php?option=com_users&view=login'); $details = array('from_email' => $config->getValue('mailfrom'), 'from_name' => $config->getValue('fromname'), 'subject' => JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename')), 'body' => JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $user->username, $url)); if (!JUtility::sendMail($details['from_email'], $details['from_name'], $email, $details['subject'], $details['body'])) { $this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_REMINDER_EMAIL'), 'error'); return false; } }
function getNotify() { global $mainframe; $db = JFactory::getDBO(); $query = 'SELECT * FROM #__bill WHERE status!=0 and notifed=0 and (unix_timestamp(tend)-unix_timestamp(now()))<=86400 and tend>now()'; $db->setQuery($query); $notyfeds = $db->loadObjectList(); foreach ($notyfeds as $notyfed) { $user =& JFactory::getUser($notyfed->userid); $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $profile = $this->getProfile($notyfed->profileid); $item = $this->getItem($notyfed->adid); $recipient = $user->email; $body = '<p>Доброго времени суток, ' . $user->name . '!</p>' . '<p>К сожалению, анонс украшения ' . $this->mb_ucfirst($item->title) . ' через 12 часов покинет место в ' . $profile->name . '.</p>' . '<p>Не забудьте заказать новое размещение.</p>' . '<p>Администрация сервиса по продаже авторских украшений Цацки-Пецки.ру</p>'; $subject = 'Размещение по счету ' . $notyfed->id . ' подходит к концу'; JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $body, $mode = 1, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null); $query = 'UPDATE #__bill SET notifed=1 WHERE id=' . $notyfed->id; $db->setQuery($query); $db->Query(); } return; }
function repeat_emails($params, &$formModel) { jimport('joomla.mail.helper'); $article_id = '70'; $email_element_name = 'fab_sponsors___sponsor_email'; $sponsorship_prefix = 'fab_sponsorship___'; $sponsorship_pk = $sponsorship_prefix . 'id'; $sponsors_join_id = 58; $email_from_addr = "*****@*****.**"; $email_from_name = "Hugh Messenger"; $email_subject = "Hi {fab_sponsors___sponsor_name}"; $user = JFactory::getUser(); $config = JFactory::getConfig(); $db = JFactory::getDbo(); $w = new FabrikWorker(); $content = repeat_emails_get_article($article_id); $sponsorship_data = array(); foreach ($formModel->_formDataWithTableName as $key => $value) { if (strstr($key, $sponsorship_prefix)) { $sponsorship_data[$key] = $value; } } $sponsorship_data[$sponsorship_pk] = $formModel->_formData[$sponsorship_pk]; $sponsorship_data[$sponsorship_pk_raw] = $formModel->_formData[$sponsorship_pk]; foreach ($formModel->_formData['join'][$sponsors_join_id][$email_element_name] as $key => $email) { $sponsor_data = array(); foreach ($formModel->_formData['join'][$sponsors_join_id] as $sponsor_key => $sponsor_val) { $sponsor_data[$sponsor_key] = $formModel->_formData['join'][$sponsors_join_id][$sponsor_key][$key]; } $email_data = array_merge($sponsorship_data, $sponsor_data); $this_content = $w->parseMessageForPlaceHolder($content, $email_data); $this_subject = $w->parseMessageForPlaceHolder($email_subject, $email_data); if (JMailHelper::isEmailAddress($email)) { $res = JUtility::sendMail($email_from_addr, $email_from_name, $email, $this_subject, $this_content, true); } } }
function getBill($item, $profile) { global $app; $user =& JFactory::getUser(); $db = JFactory::getDBO(); $query = 'INSERT INTO #__bill (tupdate,tstart,tend,adid,profileid,userid,price) VALUES(now(),0,0,' . $item->id . ',' . $profile->id . ',' . $user->id . ',' . $profile->price . ')'; $db->setQuery($query); $db->query(); $MD5 = MD5('Zazki:' . $profile->price . ':' . $db->insertid() . ':zazki2012:shp_adid=' . $item->id . ':shp_profileid=' . $profile->id); $bill_id = $db->insertid(); $query = "UPDATE #__bill SET MD5='" . $MD5 . "' WHERE id=" . $bill_id . ""; $db->setQuery($query); $db->Query(); $query = 'SELECT * FROM #__bill WHERE id=' . $bill_id . ''; $db->setQuery($query); $bill = $db->loadObject(); $mailfrom = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $recipient = $user->email; $body = '<p>' . $user->name . '!</p>' . '<p>Для размещения украшения ' . $this->mb_ucfirst($item->title) . ' на позиции ' . $profile->name . ' сформирован счет №' . $bill->id . ', стоимость ' . $profile->price . '. Как только счет будет оплачен, анонс украшения появится на выбранной позиции и покупатели будут видеть его чаще.</p>' . '<p><a href="https://merchant.roboxchange.com/Index.aspx?MrchLogin=Zazki&OutSum=' . $profile->price . '&InvId=' . $bill->id . '&Desc=' . strip_tags($profile->desc) . '&SignatureValue=' . $MD5 . '&Culture=ru&shp_adid=' . $item->id . '&shp_profileid=' . $profile->id . '">Оплатить счет</a></p>' . '<p>Отслеживать статус счета вы можете в разделе «Мои счета»</p>' . '<p>Администрация сервиса по продаже авторских украшений Цацки-Пецки.ру</p>'; $subject = 'Сформирован счет №' . $bill->id; JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $body, $mode = 1, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null); return $bill; }
function sendmail($JSecureConfig, $key, $success = null) { $config = new JConfig(); $to = $JSecureConfig->emailid; $to = $to ? $to : $config->mailfrom; if ($to) { $fromEmail = $config->mailfrom; $fromName = $config->fromname; $subject = $JSecureConfig->emailsubject; $headers = 'From: ' . $fromName . ' <' . $fromEmail . '>'; switch ($success) { case 1: $body = JText::_($key) . $_SERVER['REMOTE_ADDR']; break; default: $body = JText::_('BODY_MESSAGE:') . $_SERVER['REMOTE_ADDR']; $body .= " "; $body .= JText::_(' USING KEY: ') . $key; break; } JUtility::sendMail($fromEmail, $fromName, $to, $subject, $body, 1); //mail($to, $subject, $body, $headers); } }
function _notifyTicket() { if (!$this->is_staff) { return; } if (!RSTicketsProHelper::getConfig('autoclose_enabled')) { return; } if ($this->_ticket->last_reply_customer) { return; } if ($this->_ticket->autoclose_sent) { return; } $date = JFactory::getDate(); $date = $date->toUnix(); $date = RSTicketsProHelper::getCurrentDate($date); $this->_db->setQuery("UPDATE #__rsticketspro_tickets SET autoclose_sent='" . $date . "' WHERE id='" . $this->_ticket->id . "' LIMIT 1"); $this->_db->query(); $interval = RSTicketsProHelper::getConfig('autoclose_email_interval') * 86400; if ($interval < 86400) { $interval = 86400; } $last_reply_interval = RSTicketsProHelper::getCurrentDate($this->_ticket->last_reply) + $interval; if ($last_reply_interval > $date) { return; } $overdue = floor(($date - $last_reply_interval) / 86400); $closed = RSTicketsProHelper::getConfig('autoclose_interval'); // get email sending settings $from = RSTicketsProHelper::getConfig('email_address'); $fromname = RSTicketsProHelper::getConfig('email_address_fullname'); // are we using global ? if (RSTicketsProHelper::getConfig('email_use_global')) { $config = new JConfig(); $from = $config->mailfrom; $fromname = $config->fromname; } $department =& JTable::getInstance('RSTicketsPro_Departments', 'Table'); $department->load($this->_ticket->department_id); if (!$department->get('email_use_global')) { $from = $department->email_address; $fromname = $department->email_address_fullname; } $email = RSTicketsProHelper::getEmail('notification_email'); $customer = JFactory::getUser($this->_ticket->customer_id); $staff = JFactory::getUser($this->_ticket->staff_id); $code = $this->_ticket->code; $replace = array('{live_site}', '{ticket}', '{customer_name}', '{customer_username}', '{customer_email}', '{staff_name}', '{staff_username}', '{staff_email}', '{code}', '{subject}', '{inactive_interval}', '{close_interval}'); $with = array(JURI::root(), RSTicketsProHelper::route(JURI::root() . 'index.php?option=com_rsticketspro&view=ticket&cid=' . $this->_ticket->id . ':' . JFilterOutput::stringURLSafe($this->_ticket->subject)), $customer->get('name'), $customer->get('username'), $customer->get('email'), $staff->get('name'), $staff->get('username'), $staff->get('email'), $code, $this->_ticket->subject, $overdue, $closed); $email_subject = str_replace($replace, $with, $email->subject); $email_message = str_replace($replace, $with, $email->message); JUtility::sendMail($from, $fromname, $customer->get('email'), $email_subject, $email_message, 1); }
function sendEmails($MyForm, $emails, $posted = array()) { global $mainframe; $database =& JFactory::getDBO(); if (!count($posted)) { $posted = JRequest::get('post', JREQUEST_ALLOWRAW); } /** * Associate field values with names and implode arrays */ $fields = array(); $fields = $MyForm->handleArrays($MyForm->formrow->name); //loop emails foreach ($emails as $email) { $email_params = new JParameter($email->params); if ($email->enabled == "1") { $email_body = $email->template; ob_start(); eval("?>" . $email_body); $email_body = ob_get_clean(); //build email template from defined fields and posted fields foreach ($posted as $name => $post) { if (!is_array($post)) { $post = nl2br((string) $post); $email_body = str_replace("{" . $name . "}", $post, $email_body); } else { $email_body = str_replace("{" . $name . "}", implode(", ", $post), $email_body); } } foreach ($fields as $name => $post) { $email_body = str_replace("{" . $name . "}", $post, $email_body); } /** * Add IP address if required */ if ($email_params->get('recordip', "1") == "1") { if (!ereg("\\{IPADDRESS\\}", $email_body)) { if ($email_params->get('emailtype', "html") == "html") { $email_body .= "<br /><br />"; } $email_body .= "\nSubmitted by {IPADDRESS}"; } $email_body = str_replace('{IPADDRESS}', $_SERVER['REMOTE_ADDR'], $email_body); } $this->emailsbodies[] = $email_body; /** * Wrap page code around the html message body */ if ($email_params->get('emailtype', "html") == "html") { $email_body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\t\t\t\t\t <html>\n\t\t\t\t\t\t <head>\n\t\t\t\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n\t\t\t\t\t\t\t<base href=\"" . JURI::base() . "/\" />\n\t\t\t\t\t\t\t<title>Email</title>\n\t\t\t\t\t\t </head>\n\t\t\t\t\t\t \n\t\t\t\t\t\t <body>{$email_body}</body>\n\t\t\t\t\t </html>"; } $fromname = trim($email->fromname) ? trim($email->fromname) : $posted[trim($email->dfromname)]; $from = trim($email->fromemail) ? trim($email->fromemail) : $posted[trim($email->dfromemail)]; $subject = trim($email->subject) ? trim($email->subject) : $posted[trim($email->dsubject)]; // Recepients $recipients = array(); if (trim($email->to)) { $recipients = explode(",", trim($email->to)); } if (trim($email->dto)) { $dynamic_recipients = explode(",", trim($email->dto)); foreach ($dynamic_recipients as $dynamic_recipient) { if ($posted[trim($dynamic_recipient)]) { $recipients[] = $posted[trim($dynamic_recipient)]; } } } // CCs $ccemails = array(); if (trim($email->cc)) { $ccemails = explode(",", trim($email->cc)); } if (trim($email->dcc)) { $dynamic_ccemails = explode(",", trim($email->dcc)); foreach ($dynamic_ccemails as $dynamic_ccemail) { if ($posted[trim($dynamic_ccemail)]) { $ccemails[] = $posted[trim($dynamic_ccemail)]; } } } // BCCs $bccemails = array(); if (trim($email->bcc)) { $bccemails = explode(",", trim($email->bcc)); } if (trim($email->dbcc)) { $dynamic_bccemails = explode(",", trim($email->dbcc)); foreach ($dynamic_bccemails as $dynamic_bccemail) { if ($posted[trim($dynamic_bccemail)]) { $bccemails[] = $posted[trim($dynamic_bccemail)]; } } } // ReplyTo Names $replytonames = array(); if (trim($email->replytoname)) { $replytonames = explode(",", trim($email->replytoname)); } if (trim($email->dreplytoname)) { $dynamic_replytonames = explode(",", trim($email->dreplytoname)); foreach ($dynamic_replytonames as $dynamic_replytoname) { if ($posted[trim($dynamic_replytoname)]) { $replytonames[] = $posted[trim($dynamic_replytoname)]; } } } // ReplyTo Emails $replytoemails = array(); if (trim($email->replytoemail)) { $replytoemails = explode(",", trim($email->replytoemail)); } if (trim($email->dreplytoemail)) { $dynamic_replytoemails = explode(",", trim($email->dreplytoemail)); foreach ($dynamic_replytoemails as $dynamic_replytoemail) { if ($posted[trim($dynamic_replytoemail)]) { $replytoemails[] = $posted[trim($dynamic_replytoemail)]; } } } // Replies $replyto_email = $replytoemails; $replyto_name = $replytonames; $mode = $email_params->get('emailtype', "html") == 'html' ? true : false; if (!$mode) { $email_body = JFilterInput::clean($email_body, 'STRING'); } $this_attachments = array(); if ($email_params->get("enable_attachments", "1") == "1") { $MyUploads =& CFUploads::getInstance($MyForm->formrow->id); $this_attachments = $MyUploads->attachments; } else { $this_attachments = array(); } /** * Send the email(s) */ $email_sent = JUtility::sendMail($from, $fromname, $recipients, $subject, $email_body, $mode, $ccemails, $bccemails, $this_attachments, $replyto_email, $replyto_name); if ($email_sent) { $MyForm->addDebugMsg('An email has been SENT successfully from (' . $fromname . ')' . $from . ' to ' . implode(',', $recipients)); } if (!$email_sent) { $MyForm->addDebugMsg('An email has failed to be sent from (' . $fromname . ')' . $from . ' to ' . implode(',', $recipients)); } // :: HACK :: insert debug if ($MyForm->formparams('debug')) { echo "<h4>E-mail message</h4>\n\t\t\t\t\t<div style='border:1px solid black; padding:6px;margin:6px;'>\n\t\t\t\t\t<p>From: {$fromname} [{$from}]<br />\n\t\t\t\t\tTo: " . implode(', ', $recipients) . "<br />\n\t\t\t\t\tCC: " . implode(', ', $ccemails) . "<br />\n\t\t\t\t\tBCC: " . implode(', ', $bccemails) . "<br />\n\t\t\t\t\tSubject: {$subject}</p>\n\t\t\t\t\t{$email_body}<br /><br />\n\t\t\t\t\tFiles: " . implode(', ', $this_attachments) . "<br /></div>"; } } } return $emails; }