public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); if (!$uid) { return true; } $body = $this->body(); $body .= $this->attachments(); $body .= PHP_EOL; $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $body = nl2br($body); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert($db->quoteName("#__messages")); $query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid)); $query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid)); $query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql())); $query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")")); $query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), B2JMessageBoard::error); return false; } return true; }
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; }
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 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; }
/** * @group framework.mail * @dataProvider getCleanBodyData */ public function testCleanBody( $input, $expected ) { $this->assertThat( JMailHelper::cleanBody( $input ), $this->equalTo( $expected ) ); }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); // No user selected for Joomla messenger if (!$uid) { //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this)); // It's not a problem. Maybe it's even wanted. Return succesful. return true; } $body = $this->body(); $body .= $this->attachments(); $body .= PHP_EOL; // Info about url $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; // Info about client $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert($db->quoteName("#__messages")); $query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid)); $query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid)); $query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql())); $query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")")); $query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { //JLog::add($msg, JLog::ERROR, get_class($this)); $this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), FoxMessageBoard::error); // Database problems. Return error. return false; } //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this)); return true; }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); // No user selected for Joomla messenger if (!$uid) { //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this)); // It's not a problem. Maybe it's even wanted. Return succesful. return true; } $body = $this->body(); $body .= $this->attachments(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert("#__messages"); $query->columns(array($db->quoteName('user_id_from'), $db->quoteName('user_id_to'), $db->quoteName('date_time'), $db->quoteName('subject'), $db->quoteName('message'))); $query->values($uid . ", " . $uid . ", " . $db->Quote(JFactory::getDate()->toSql()) . ", " . $db->Quote($this->submittername() . " (" . $this->submitteraddress() . ")") . ', ' . $db->Quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); if (!$db->query()) { $msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"); //JLog::add($msg, JLog::ERROR, get_class($this)); $this->Messages[] = $msg; // Database problems. Return error. return false; } //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this)); return true; }
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(JMailHelper::cleanSubject($this->Params->get("email_subject", ""))); $body = $this->body(); $body .= $this->attachments($mail); $body .= PHP_EOL; $body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL; $body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL; $body = JMailHelper::cleanBody($body); $mail->setBody($body); $this->Logger->Write("---------------------------------------------------" . PHP_EOL . $body); return $this->send($mail); }
public function Process() { $uid = $this->Params->get("jmessenger_user", NULL); // No user selected for Joomla messenger if (!$uid) { //JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this)); // It's not a problem. Maybe it's even wanted. Return succesful. return true; } $body = $this->body(); $body .= $this->attachments(); $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; $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->insert($db->quoteName("#__messages")); $query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid)); $query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid)); $query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql())); $query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")")); $query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body))); $db->setQuery((string) $query); try { $db->execute(); } catch (RuntimeException $e) { // Show a generic database error $this->MessageBoard->Add(JText::_("COM_FOXCONTACT_ERR_SENDING_MESSAGE"), FoxMessageBoard::error); // Log the details which may contain sensitive data $this->Logger->Write($e->getMessage()); // Database problems. Return error. return false; } // Log the successful event to the database. Intentionally not in the user's language. $this->Logger->Write("Private message sent to Joomla messenger."); //JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this)); return true; }
public function Process() { $application = JFactory::getApplication(); $copy_to_submitter = $application->input->post->get($this->SafeName("copy_to_submitter" . $this->GetId()), false, "bool") || $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->session->clear("filelist", $this->namespace); //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 . JFactory::getConfig()->get("sitename") . PHP_EOL; $body = JMailHelper::cleanBody($body); $mail->setBody($body); // Clear file list for the next submission of the same users $this->session->clear("filelist", $this->namespace); $sent = $this->send($mail); if ($sent) { // Notify email send success $this->Logger->Write("Copy email sent."); } return $sent; }
function sendEditCoupon(&$item, &$field, $email, $token) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $SiteName = $app->getCfg('sitename'); $mailfrom = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); // Check for a valid from address if (!$mailfrom || !JMailHelper::isEmailAddress($mailfrom)) { $notice = JText::sprintf('FLEXI_ACCOUNT_V_SUBMIT_INVALID_EMAIL', $mailfrom); JError::raiseWarning(0, $notice); } $subject = JText::sprintf('FLEXI_ACCOUNT_V_SUBMIT_YOUR_NEW_ITEM_AT', $SiteName); $desc = JText::_($field->parameters->get('coupon_desc'), '...'); $link = JRoute::_(JURI::root(false) . FlexicontentHelperRoute::getItemRoute($item->id, $item->catid) . '&task=edit&edittok=' . $token); // Build the message to send $body = JText::sprintf('FLEXI_ACCOUNT_V_SUBMIT_EDIT_LINK_SEND_INFO', $SiteName, $fromname, $mailfrom, $link); $body .= "\n\n" . $desc; // Extra text // Clean the email data $emailSubject = JMailHelper::cleanSubject($subject); $emailBody = JMailHelper::cleanBody($body); $fromname = JMailHelper::cleanAddress($fromname); $recipient = array($email); $html_mode = true; $cc = null; $bcc = null; $attachment = null; $replyto = null; $replytoname = null; // Send the email $send_result = JFactory::getMailer()->sendMail($mailfrom, $fromname, $recipient, $emailSubject, $emailBody, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname); if ($send_result !== true) { JError::raiseWarning(500, JText::_('FLEXI_ACCOUNT_V_SUBMIT_EDIT_LINK_NOT_SENT')); return false; } return true; }
protected function _sendReportToMail($message, $subject, $emailToList) { jimport('joomla.mail.helper'); $sender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_GEN_FORUM') . ': ' . $this->_getSenderName()); $subject = JMailHelper::cleanSubject($subject); $message = JMailHelper::cleanBody($message); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } JUtility::sendMail($this->config->email, $sender, $emailTo->email, $subject, $message); } $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS')); while (@ob_end_clean()) { } $this->app->redirect(CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, NULL, NULL, $this->id, false)); }
/** * Send email with download (file) link, to the given email address * * @access public * @since 1.0 */ function share_file_email() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $db = JFactory::getDbo(); $app = JFactory::getApplication(); $session = JFactory::getSession(); $document = JFactory::getDocument(); $timeout = $session->get('com_flexicontent.formtime', 0); if ($timeout == 0 || time() - $timeout < 2) { JError::raiseNotice(500, JText::_('FLEXI_FIELD_FILE_EMAIL_NOT_SENT')); return $this->share_file_form(); } $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $file_id = (int) JRequest::getInt('file_id', 0); $content_id = (int) JRequest::getInt('content_id', 0); $field_id = (int) JRequest::getInt('field_id', 0); $tpl = JRequest::getCmd('$tpl', 'default'); // Check for missing file id if (!$file_id) { jexit(JText::_('file id is missing')); } // Check file exists $query = ' SELECT * FROM #__flexicontent_files WHERE id=' . $file_id; $db->setQuery($query); $file = $db->loadObject(); if ($db->getErrorNum()) { jexit(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg())); } if (!$file) { jexit(JText::_('file id no ' . $file_id . ', was not found')); } // Create SELECT OR JOIN / AND clauses for checking Access $access_clauses['select'] = ''; $access_clauses['join'] = ''; $access_clauses['and'] = ''; $access_clauses = $this->_createFieldItemAccessClause($get_select_access = false, $include_file = true); // Get field's configuration $q = 'SELECT attribs, name FROM #__flexicontent_fields WHERE id = ' . (int) $field_id; $db->setQuery($q); $fld = $db->loadObject(); $field_params = new JRegistry($fld->attribs); // Get all needed data related to the given file $query = 'SELECT f.id, f.filename, f.altname, f.secure, f.url,' . ' i.title as item_title, i.introtext as item_introtext, i.fulltext as item_fulltext, u.email as item_owner_email, ' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as itemslug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__flexicontent_fields_item_relations AS rel' . ' LEFT JOIN #__flexicontent_files AS f ON f.id = rel.value' . ' LEFT JOIN #__flexicontent_fields AS fi ON fi.id = rel.field_id' . ' LEFT JOIN #__content AS i ON i.id = rel.item_id' . ' LEFT JOIN #__categories AS c ON c.id = i.catid' . ' LEFT JOIN #__flexicontent_items_ext AS ie ON ie.item_id = i.id' . ' LEFT JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id' . ' LEFT JOIN #__users AS u ON u.id = i.created_by' . $access_clauses['join'] . ' WHERE rel.item_id = ' . $content_id . ' AND rel.field_id = ' . $field_id . ' AND f.id = ' . $file_id . ' AND f.published= 1' . $access_clauses['and']; $db->setQuery($query); $file = $db->loadObject(); if ($db->getErrorNum()) { jexit(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg())); } if (empty($file)) { // this is normally not reachable because the share link should not have been displayed for the user, but it is reachable if e.g. user session has expired jexit(JText::_('FLEXI_ALERTNOTAUTH') . "File data not found OR no access for file #: " . $file_id . " of content #: " . $content_id . " in field #: " . $field_id); } $coupon_vars = ''; if ($field_params->get('enable_coupons', 0)) { // Insert new download coupon into the DB, in the case the file is sent to a user with no ACCESS $coupon_token = uniqid(); // create coupon token $query = ' INSERT #__flexicontent_download_coupons ' . 'SET user_id = ' . (int) $user->id . ', file_id = ' . $file_id . ', token = ' . $db->Quote($coupon_token) . ', hits = 0' . ', hits_limit = ' . (int) $field_params->get('coupon_hits_limit', 3) . ', expire_on = NOW() + INTERVAL ' . (int) $field_params->get('coupon_expiration_days', 15) . ' DAY'; $db->setQuery($query); $db->execute(); $coupon_id = $db->insertid(); // get id of newly created coupon $coupon_vars = '&conid=' . $coupon_id . '&contok=' . $coupon_token; } $uri = JURI::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $vars = '&id=' . $file_id . '&cid=' . $content_id . '&fid=' . $field_id . $coupon_vars; $link = $base . JRoute::_('index.php?option=com_flexicontent&task=download' . $vars, false); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText::_('FLEXI_FIELD_FILE_EMAIL_NOT_SENT')); return $this->share_file_form(); } // An array of email headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); echo "<br>"; $sender = JRequest::getString('sender', '', 'post'); echo "<br>"; $from = JRequest::getString('from', '', 'post'); echo "<br>"; $_subject = JText::sprintf('FLEXI_FIELD_FILE_SENT_BY', $sender); echo "<br>"; $subject = JRequest::getString('subject', $_subject, 'post'); echo "<br>"; $desc = JRequest::getString('desc', '', 'post'); echo "<br>"; // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('FLEXI_FIELD_FILE_EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('FLEXI_FIELD_FILE_EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->share_file_form(); } // Build the message to send $body = JText::sprintf('FLEXI_FIELD_FILE_EMAIL_MSG', $SiteName, $sender, $from, $link); $body .= "\n\n" . JText::_('FLEXI_FIELD_FILE_EMAIL_SENDER_NOTES') . ":\n\n" . $desc; // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); $html_mode = false; $cc = null; $bcc = null; $attachment = null; $replyto = null; $replytoname = null; // Send the email $send_result = JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body, $html_mode, $cc, $bcc, $attachment, $replyto, $replytoname); if ($send_result !== true) { JError::raiseNotice(500, JText::_('FLEXI_FIELD_FILE_EMAIL_NOT_SENT')); return $this->share_file_form(); } $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css', FLEXI_VHASH); include 'file' . DS . 'share_result.php'; }
function sendEmailToModeratorsPostWFM() { // get settings from com_discussions parameters $params = JComponentHelper::getParams('com_discussions'); $SiteName = $params->get('emailSiteName', ''); $from = $params->get('emailFrom', ''); $sender = $params->get('emailSender', ''); $link = $params->get('emailLink', ''); $subject = $params->get('emailWFMSubject', ''); $msgparam = $params->get('emailWFMMessage', ''); jimport('joomla.mail.helper'); $db =& JFactory::getDBO(); // get all moderators with email notifications set $sql = "SELECT u.username, u.email FROM " . $db->nameQuote('#__users') . " u, " . $db->nameQuote('#__discussions_users') . " d" . " WHERE u.id = d.id AND d.moderator = 1 AND d.email_notification = 1"; $db->setQuery($sql); $_moderator_list = $db->loadAssocList(); reset($_moderator_list); while (list($key, $val) = each($_moderator_list)) { $username = $_moderator_list[$key]['username']; $email = $_moderator_list[$key]['email']; if (JMailHelper::isEmailAddress($email)) { // construct email $msg = $username . ", \n\n" . $msgparam; $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); JUtility::sendMail($from, $sender, $email, $subject, $body); } } return 0; }
function sendEmail($configData,$formData) { // build the message body from the configured fields $body = "From ".$formData['fromName']." at ".$formData['fromAddress']."\r\n"; if (!empty($formData['list1'])) $body .= $configData['list_prompt'].": ".$configData['list_array'][$formData['list1']]."\r\n"; if (!empty($formData['line1'])) $body .= $configData['line1_prompt'].": ".$formData['line1']."\r\n"; if (!empty($formData['line2'])) $body .= $configData['line2_prompt'].": ".$formData['line2']."\r\n"; if (!empty($formData['line3'])) $body .= $configData['line3_prompt'].": ".$formData['line3']."\r\n"; if (!empty($formData['line4'])) $body .= $configData['line4_prompt'].": ".$formData['line4']."\r\n"; if (!empty($formData['line5'])) $body .= $configData['line5_prompt'].": ".$formData['line5']."\r\n"; if (!empty($formData['area_data'])) $body .= $configData['area_prompt'].": ".$formData['area_data']."\r\n"; // make sure the body and subject don't contain anything they shouldn't jimport('joomla.mail.helper'); $body = JMailHelper::cleanBody($body); $subject = JMailHelper::cleanSubject($formData['subject']); // get the client information $ip = getIPaddress(); $ipmsg = "Client IP: ".$ip."\r\n"; $ipmsg .= $_SERVER["HTTP_USER_AGENT"]."\r\n"; // from version 2.11 we now send the mail using the Joomla sendMail function (instead of php mail) // which uses the mail settings configured in Joomla Global Configuration $app = &JFactory::getApplication(); $from = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $recipient = $configData['toPrimary']; $cc = $configData['cc']; $bcc = $configData['bcc']; $replyto = $formData['fromAddress']; $replytoname = $formData['fromName']; // from version 2.15 we build the mail object ourselves so that we can get at the ErrorInfo $mail =& JFactory::getMailer(); $mail->setSender(array($from, $fromname)); $mail->setSubject($subject); $mail->setBody($body.$ipmsg); $mail->addRecipient($recipient); if ($cc != '') $mail->addCC($cc); if ($bcc != '') $mail->addBCC($bcc); $mail->addReplyTo(array($replyto, $replytoname)); $ret_main = $mail->Send(); if ($ret_main === true) $status = "Sent OK\r\n"; else $status = "Mail was NOT accepted for delivery (".$mail->ErrorInfo.")\r\n"; logText(JText::_('SUBJECT').": $subject\r\n". "To: $recipient\r\n". "From: $fromname at $from\r\n". "Cc: $cc\r\n". "Bcc: $bcc\r\n". "ReplyTo: $replytoname at $replyto\r\n". $ipmsg. $body. $status. "-------------------------\r\n"); // if the user wanted a copy, send that separately if ($formData['copyMe'] == 1) { $mail =& JFactory::getMailer(); $mail->setSender(array($from, $fromname)); $mail->setSubject($subject); $mail->setBody($body); $mail->addRecipient($formData['fromAddress']); $ret_copy = $mail->Send(); if ($ret_copy === true) $status = "Sent OK\r\n"; else $status = "Mail was NOT accepted for delivery (".$mail->ErrorInfo.")\r\n"; logText("Copy to: $recipient\r\n". $status. "-------------------------\r\n"); } return $ret_main; }
function save_comment($cachable = false, $urlparams = array()) { JRequest::checkToken(); $app = JFactory::getApplication(); $view = $this->getView('singleimage', 'html'); /** * @var EventgalleryModelSingleimage $model */ $model = $this->getModel('singleimage'); $view->setModel($model); $modelComment = $this->getModel('comment'); $buzzwords = $model->getBuzzwords(); $buzzwordsClean = BuzzwordsHelper::validateBuzzwords($buzzwords, JRequest::getVar('text')); $data = JRequest::getVar('jform', array(), 'post', 'array'); $form = $modelComment->getForm(); $validate = $modelComment->validate($form, $data); if ($validate === false || !$buzzwordsClean) { // Get the validation messages. $errors = $modelComment->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_eventgallery.comment.data', $data); // Redirect back to the contact form. $msg = JText::_('COM_EVENTGALLERY_SINGLEIMAGE_COMMENT_SAVE_FAILED'); $this->setRedirect(JRoute::_("index.php?view=singleimage&success=false&folder=" . JRequest::getVar('folder') . "&file=" . JRequest::getVar('file'), false), $msg, 'error'); return false; } $validate['file'] = JRequest::getString('file'); $validate['folder'] = JRequest::getString('folder'); $row = $model->store_comment($validate, $buzzwordsClean ? 1 : 0); // reset the user state $app->setUserState('com_eventgallery.comment.data', null); $msg = JText::_('COM_EVENTGALLERY_SINGLEIMAGE_COMMENT_SAVE_SUCCESS'); $this->setRedirect(JRoute::_("index.php?view=singleimage&success=true&folder=" . JRequest::getVar('folder') . "&file=" . JRequest::getVar('file'), false), $msg, 'success'); $mailer = JFactory::getMailer(); $params = JComponentHelper::getParams('com_eventgallery'); $userids = JAccess::getUsersByGroup($params->get('admin_usergroup')); if (count($userids) == 0) { return; } foreach ($userids as $userid) { $user = JUser::getInstance($userid); if ($user->sendEmail == 1) { $mailadress = JMailHelper::cleanAddress($user->email); $mailer->addRecipient($mailadress); } } $config = JFactory::getConfig(); $sender = array($config->get('mailfrom'), $config->get('fromname')); $mailer->setSender($sender); JRequest::setVar('newCommentId', $row->id); $mailview = $this->getView('commentmail', 'html'); /** * * @var EventgalleryModelComment $commentModel */ $commentModel = $this->getModel('comment'); $mailview->setModel($commentModel, true); $bodytext = $mailview->loadTemplate(); #$mailer->LE = "\r\n"; $mailer->LE = "\n"; $bodytext = JMailHelper::cleanBody($bodytext); $mailer->setSubject(JMailHelper::cleanSubject($row->folder . "|" . $row->file . ' - ' . JText::_('COM_EVENTGALLERY_COMMENT_ADD_MAIL_SUBJECT') . ' - ' . $app->getCfg('sitename'))); $mailer->SetBody($bodytext); $mailer->IsHTML(true); $mailer->Send(); }
/** * Sends email for ContactFormPro. * * Message information is extract from Post vars. * * @return object */ static function sendmail() { jimport('joomla.mail.helper'); $params = self::getParams(); $response->status = 1001; $response->message = ""; if (JRequest::getString("error_message")) { $response->message .= html_entity_decode(urldecode(JRequest::getString("error_message"))); } else { $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_GENERIC_ERROR') . '</p>'; } if (!JRequest::checkToken()) { $respons->status = 9999; $response->message .= '<p>' . JText::_('JINVALID_TOKEN') . '</p>'; } // Check for a valid session cookie if ($params->get('validate_session', 0)) { if (JFactory::getSession()->getState() != 'active') { $respons->status = 9999; $response->message .= '<p>' . JText::_('JINVALID_TOKEN') . '</p>'; } } $debug = JRequest::getVar('debug'); $mailto = JRequest::getVar('mailto'); if ($mailto) { $mailto = base64_decode($mailto); $mailto = explode(';', $mailto); } else { $response->status = 1101; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_MAILTO_MISSING') . '</p>'; } $sender_email = JRequest::getVar('sender_email'); if (!$sender_email || !JMailHelper::isEmailAddress($sender_email)) { $response->status = 1201; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_SENDER_EMAIL_MISSING') . '</p>'; } $message = stripslashes(JRequest::getVar('message')); if (!$message || $message == '') { $response->status = 1301; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_MESSAGE_MISSING') . '</p>'; } $sender_name = stripslashes(JRequest::getVar('sender_name')); if (!$sender_name || $sender_name == '') { $response->status = 1401; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_SENDER_NAME_MISSING') . '</p>'; } $subject = stripslashes(JRequest::getVar('subject')); if (!$subject || $subject == '') { $response->status = 1501; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_SUBJECT_MISSING') . '</p>'; } if (!CFPHelper::validateCaptcha()) { $response->status = 1601; $response->message .= '<p>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_CAPTCHA_REQUIRE') . '</p>'; } if ($response->status > 1001) { return $response; } $encoding = JRequest::getVar('encoding'); $encoding || ($encoding = "UTF-8"); // header injection test // An array of e-mail headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender_name', 'sender_email', 'subject'); // iterate over variables and search for headers foreach ($fields as $field) { foreach ($headers as $header) { if (strpos(JRequest::getVar($field), $header) !== false) { JError::raiseError(403, ''); } } } unset($headers, $fields); $emailSubject = sprintf(JText::_('PLG_SYSTEM_CONTACTFORMPRO_EMAIL_SUBJECT'), $sender_name); // add header $emailBody = ' <p><b>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_SUBJECT_LABEL') . '</b>: ' . JMailHelper::cleanBody($subject) . '</p> <p></p> <p><b>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_MESSAGE_LABEL') . ' : </b></p> <p>' . JMailHelper::cleanBody(nl2br($message)) . '</p> <p></p> <p>' . $sender_name . ' <br />' . $sender_email . '</p> <p></p> <p></p> <p><small>' . JText::_('PLG_SYSTEM_CONTACTFORMPRO_GENERATED_BY') . $_SERVER['HTTP_REFERER'] . '</small></p>'; $emailBody = mb_convert_encoding($emailBody, 'HTML-ENTITIES', $encoding); $adminemail = $params->get('fixedaddress'); if ($adminemail) { $bcc = explode(';', $adminemail); } else { $bcc = array(); } if (JRequest::getBool('receive_copy')) { $bcc[] = $sender_email; } $error_info = CFPHelper::_send_email($sender_name, $sender_email, $mailto, $emailSubject, $emailBody, $bcc, true); if ($error_info == '') { $response->status = 1; if (JRequest::getString("success_message")) { $response->message = html_entity_decode(urldecode(JRequest::getString("success_message"))); } else { $response->message = JText::_('PLG_SYSTEM_CONTACTFORMPRO_SUCCESS'); } } else { $response->status = 1501; if (JRequest::getString("error_message")) { $response->message = html_entity_decode(urldecode(JRequest::getString("success_message"))); } else { if ($debug) { $response->message = $error_info; } else { $response->message = JText::_('PLG_SYSTEM_CONTACTFORMPRO_GENERIC_ERROR'); } } } return $response; }
function report() { if (!JRequest::checkToken()) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->redirectBack(); } if (!$this->me->exists() || $this->config->reportmsg == 0) { // Deny access if report feature has been disabled or user is guest $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice'); $this->redirectBack(); } if (!$this->config->get('send_emails')) { // Emails have been disabled $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice'); $this->redirectBack(); } jimport('joomla.mail.helper'); if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) { // Error: email address is invalid $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error'); $this->redirectBack(); } // Get target object for the report if ($this->mesid) { $message = $target = KunenaForumMessageHelper::get($this->mesid); $topic = $target->getTopic(); } else { $topic = $target = KunenaForumTopicHelper::get($this->id); $message = KunenaForumMessageHelper::get($topic->first_post_id); } $messagetext = $message->message; $baduser = KunenaFactory::getUser($message->userid); if (!$target->authorise('read')) { // Deny access if user cannot read target $this->app->enqueueMessage($target->getError(), 'notice'); $this->redirectBack(); } $category = $topic->getCategory(); $reason = JRequest::getString('reason'); $text = JRequest::getString('text'); if (empty($reason) && empty($text)) { // Do nothing: empty subject or reason is empty $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES')); $this->redirectBack(); } else { $acl = KunenaAccess::getInstance(); $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false, $this->me->userid); if (!empty($emailToList)) { $mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName()); $mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": "; if ($reason) { $mailsubject .= $reason; } else { $mailsubject .= $topic->subject; } jimport('joomla.environment.uri'); $uri = JURI::getInstance(JURI::base()); $msglink = $uri->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false); $mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text; $mailmessage .= "\n\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false); $mailmessage .= "\n-----\n\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink; $mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array(' ' => ''))); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } JUtility::sendMail($this->config->getEmail(), $mailsender, $emailTo->email, $mailsubject, $mailmessage); } $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS')); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND')); } } $this->app->redirect($target->getUrl($this->return, false)); }
function doemail() { jimport('joomla.mail.helper'); jimport('joomla.filesystem.file'); jimport('joomla.client.helper'); global $mainframe; JClientHelper::setCredentialsFromRequest('ftp'); $config =& JFactory::getConfig(); $folder = ''; $filepaths = array(); $attached = 0; $notattached = 0; foreach (JRequest::get('FILES') as $elname => $file) { if ($file['name'] != '') { if ($folder == '') { $folder = $config->getValue('config.tmp_path') . DS . uniqid('com_fabrik.plg.table.emailtableplus.'); if (!JFolder::create($folder)) { JError::raiseWarning(E_NOTICE, JText::_('Could not upload files')); break; } } $filepath = $folder . DS . JFile::makeSafe($file['name']); if (JFile::upload($file['tmp_name'], $filepath)) { $filepaths[count($filepaths)] = $filepath; $attached++; } else { JError::raiseWarning(E_NOTICE, JText::sprintf('Could not upload file %s', $file['name'])); } } } $renderOrder = JRequest::getInt('renderOrder', 0); $subject = JMailHelper::cleanSubject(JRequest::getVar('subject')); $message = JMailHelper::cleanBody(JRequest::getVar('message')); $recordids = explode(',', JRequest::getVar('recordids')); $tableModel =& $this->getModel('Table'); $tableModel->setId(JRequest::getVar('id', 0)); $formModel =& $tableModel->getForm(); $this->formModel =& $formModel; $params =& $tableModel->getParams(); $elementModel =& JModel::getInstance('element', 'FabrikModel'); $field_name = $params->get('emailtableplus_field_name'); if (is_array($field_name)) { $field_name = $field_name[$renderOrder]; } $elementModel->setId($field_name); $element =& $elementModel->getElement(true); $tonamefield = $elementModel->getFullName(false, true, false); $field_email = $params->get('emailtableplus_field_email'); if (is_array($field_email)) { $field_email = $field_email[$renderOrder]; } $elementModel->setId($field_email); $element =& $elementModel->getElement(true); $tofield = $elementModel->getFullName(false, true, false); $fromUser = $params->get('emailtableplus_from_user'); if (is_array($fromUser)) { $fromUser = $fromUser[$renderOrder]; } if ($fromUser[0]) { $my =& JFactory::getUser(); $from = $my->get('email'); $fromname = $my->get('name'); } else { $config =& JFactory::getConfig(); $from = $config->getValue('mailfrom'); $fromname = $config->getValue('fromname'); } $ubcc = $params->get('emailtableplus_use_BCC'); if (is_array($ubcc)) { $ubcc = $ubcc[$renderOrder]; } $useBCC = $ubcc && count($recordids) > 0 && !preg_match('/{[^}]*}/', $subject) && !preg_match('/{[^}]*}/', $message); /* $include_rowdata = $params->get('emailtableplus_include_rowdata'); if (is_array($include_rowdata)) { $include_rowdata = $include_rowdata[$renderOrder]; } */ $sent = 0; $notsent = 0; if ($useBCC) { $bcc = array(); foreach ($recordids as $id) { $row = $tableModel->getRow($id); //$message .= $this->_getTextEmail( JArrayHelper::fromObject($row)); $to = $row->{$tofield}; $toname = $row->{$tonamefield}; if (JMailHelper::cleanAddress($to) && JMailHelper::isEmailAddress($to)) { $tofull = '"' . JMailHelper::cleanLine($toname) . '" <' . $to . '>'; $bcc[$sent] = $tofull; $sent++; } else { $notsent++; } } // $$$ hugh - working round bug in the SMTP mailer method: // http://forum.joomla.org/viewtopic.php?f=199&t=530189&p=2190233#p2190233 // ... which basically means if using the SMTP method, we MUST specify a To addrees, // so if mailer is smtp, we'll set the To address to the same as From address if ($config->getValue('mailer') == 'smtp') { $res = JUtility::sendMail($from, $fromname, $from, $subject, $message, 0, null, $bcc, $filepaths); } else { $res = JUtility::sendMail($from, $fromname, null, $subject, $message, 0, null, $bcc, $filepaths); } if (!$res) { $notsent += $sent; $sent = 0; } } else { $w = new FabrikWorker(); foreach ($recordids as $id) { $row = $tableModel->getRow($id); $to = $row->{$tofield}; $toname = $row->{$tonamefield}; if (JMailHelper::cleanAddress($to) && JMailHelper::isEmailAddress($to)) { $tofull = '"' . JMailHelper::cleanLine($toname) . '" <' . $to . '>'; $thissubject = $w->parseMessageForPlaceholder($subject, $row); $thismessage = $w->parseMessageForPlaceholder($message, $row); $res = JUtility::sendMail($from, $fromname, $tofull, $thissubject, $thismessage, 0, null, null, $filepaths); if ($res) { $sent++; } else { $notsent++; } } else { $notsent++; } } } if ($folder != '') { JFolder::delete($folder); } if ($attached > 0) { $mainframe->enqueueMessage(JText::sprintf('%s files attached', $attached)); } $mainframe->enqueueMessage(JText::sprintf('%s emails sent', $sent)); if ($notsent != 0) { JError::raiseWarning(E_NOTICE, JText::sprintf('%s emails not sent', $notsent)); } }
/** * @param int $subscription * @param string $subject * @param string $url * @param string $message * @param bool $once * * @return string */ protected function createEmailBody($subscription, $subject, $url, $message, $once) { $config = KunenaFactory::getConfig(); if ($subscription) { $msg1 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT' ); $msg2 = $this->get ( 'parent' ) ? JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2' ) : JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT' ); } else { $msg1 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD1' ); $msg2 = JText::_ ( 'COM_KUNENA_POST_EMAIL_MOD2' ); } $msg = $msg1 . " " . $config->board_title . "\n\n"; // DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body $msg .= JText::_ ( 'COM_KUNENA_MESSAGE_SUBJECT' ) . " : " . $subject . "\n"; $msg .= JText::_ ( 'COM_KUNENA_CATEGORY' ) . " : " . $this->getCategory()->name . "\n"; $msg .= JText::_ ( 'COM_KUNENA_VIEW_POSTED' ) . " : " . $this->getAuthor()->getName('???', false) . "\n\n"; $msg .= "URL : $url\n\n"; if ($config->mailfull == 1) { $msg .= JText::_ ( 'COM_KUNENA_MESSAGE' ) . " :\n-----\n"; $msg .= $message; $msg .= "\n-----\n\n"; } $msg .= $msg2 . "\n"; if ($subscription && $once) { if ($this->parent) { $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ' ) . "\n"; } else { $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE' ) . "\n"; } } $msg .= "\n"; $msg .= JText::_ ( 'COM_KUNENA_POST_EMAIL_NOTIFICATION3' ) . "\n"; return JMailHelper::cleanBody ( $msg ); }
function report() { if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } if (!$this->me->exists() || $this->config->reportmsg == 0) { // Deny access if report feature has been disabled or user is guest $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice'); $this->setRedirectBack(); return; } if (!$this->config->get('send_emails')) { // Emails have been disabled $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice'); $this->setRedirectBack(); return; } if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) { // Error: email address is invalid $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error'); $this->setRedirectBack(); return; } // Get target object for the report if ($this->mesid) { $message = $target = KunenaForumMessageHelper::get($this->mesid); $topic = $target->getTopic(); } else { $topic = $target = KunenaForumTopicHelper::get($this->id); $message = KunenaForumMessageHelper::get($topic->first_post_id); } $messagetext = $message->message; $baduser = KunenaFactory::getUser($message->userid); if (!$target->authorise('read')) { // Deny access if user cannot read target $this->app->enqueueMessage($target->getError(), 'notice'); $this->setRedirectBack(); return; } $reason = JRequest::getString('reason'); $text = JRequest::getString('text'); $template = KunenaTemplate::getInstance(); if (method_exists($template, 'reportMessage')) { $template->reportMessage($message, $reason, $text); } // Load language file from the template. KunenaFactory::getTemplate()->loadLanguage(); if (empty($reason) && empty($text)) { // Do nothing: empty subject or reason is empty $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES')); $this->setRedirectBack(); return; } else { $acl = KunenaAccess::getInstance(); $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false); if (!empty($emailToList)) { $mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName()); $mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": "; if ($reason) { $mailsubject .= $reason; } else { $mailsubject .= $topic->subject; } jimport('joomla.environment.uri'); $msglink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false); $mail = JFactory::getMailer(); $mail->setSender(array($this->me->username, $this->me->email)); $mail->setSubject($mailsubject); // Render the email. $layout = KunenaLayout::factory('Email/Report')->debug(false)->set('mail', $mail)->set('message', $message)->set('me', $this->me)->set('title', $reason)->set('content', $text)->set('messageLink', $msglink); try { $body = trim($layout->render()); $mail->setBody($body); } catch (Exception $e) { // TODO: Deprecated in K4.0, remove in K5.0 $mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text; $mailmessage .= "\n\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})"; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject; $mailmessage .= "\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false); $mailmessage .= "\n-----\n\n"; $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink; $mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array(' ' => ''))); $mail->setBody($mailmessage); } $receivers = array(); foreach ($emailToList as $emailTo) { if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) { continue; } $receivers[] = $emailTo->email; } KunenaEmail::send($mail, $receivers); $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS')); } else { $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND')); } } $this->setRedirect($target->getUrl($this->return, false)); }
function sendReply() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // read the data from the form $postData = JRequest::get('post'); $postData = $this->securityCheck($postData); // clear body and subject jimport('joomla.mail.helper'); // make sure the data is valid $isOk = true; if (!JMailHelper::isEmailAddress($postData['reply_email_address'])) { $this->_app->_session->set('isOK:' . $this->_sTask, false); $this->_app->_session->set('errorMsg:' . $this->_sTask, JText::_('COM_AICONTACTSAFE_PLEASE_ENTER_A_VALID_EMAIL_ADDRESS')); } else { if (strlen(trim($postData['reply_subject'])) == 0) { $this->_app->_session->set('isOK:' . $this->_sTask, false); $this->_app->_session->set('errorMsg:' . $this->_sTask, JText::_('COM_AICONTACTSAFE_PLEASE_SPECIFY_A_SUBJECT')); } else { if (strlen(trim($postData['reply_message'])) == 0) { $this->_app->_session->set('isOK:' . $this->_sTask, false); $this->_app->_session->set('errorMsg:' . $this->_sTask, JText::_('COM_AICONTACTSAFE_PLEASE_SPECIFY_A_MESSAGE')); } } } $isOk = $this->_app->_session->get('isOK:' . $this->_sTask); if ($isOk) { $from = $this->_app->getCfg('mailfrom'); $fromname = $this->_app->getCfg('fromname'); $email_recipient = JMailHelper::cleanAddress($postData['reply_email_address']); $subject = JMailHelper::cleanSubject($postData['reply_subject']); if (array_key_exists('send_plain_text', $postData) && $postData['send_plain_text']) { $mode = false; $body = JMailHelper::cleanBody($postData['reply_message']); } else { $mode = true; $body = JMailHelper::cleanBody(str_replace("\n", '<br />', $postData['reply_message'])); } $cc = null; $bcc = null; $replyto = $from; $replytoname = $fromname; $file_attachments = null; $isOK = JUtility::sendMail($from, $fromname, $email_recipient, $subject, $body, $mode, $cc, $bcc, $file_attachments, $replyto, $replytoname); } if ($isOk) { // initialize the database $db = JFactory::getDBO(); // update the reply $query = 'UPDATE #__aicontactsafe_messages SET email_reply = \'' . $this->replace_specialchars($email_recipient) . '\', subject_reply = \'' . $this->replace_specialchars($subject) . '\' , message_reply = \'' . $this->replace_specialchars($body) . '\' WHERE id = ' . (int) $postData['id']; $db->setQuery($query); $db->query(); // modify the status of the message accordingly $this->changeStatusToReplied((int) $postData['id']); } return $isOk; }
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $session =& JFactory::getSession(); $db =& JFactory::getDBO(); // we return time() instead of 0 (as it previously was), so that the session variable has to be set in order to send the mail $timeout = $session->get('com_mailto.formtime', time()); if ($timeout == 0 || time() - $timeout < MAILTO_TIMEOUT) { JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } // here we unset the counter right away so that you have to wait again, and you have to visit mailto() first $session->set('com_mailto.formtime', null); jimport('joomla.mail.helper'); $SiteName = $mainframe->getCfg('sitename'); $MailFrom = $mainframe->getCfg('mailfrom'); $FromName = $mainframe->getCfg('fromname'); $link = base64_decode(JRequest::getVar('link', '', 'post', 'base64')); // Verify that this is a local link if (!JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } // An array of e-mail headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $subject_default = JText::sprintf('Item sent by', $sender); $subject = JRequest::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = JText::_('EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JUtility::sendMail($from, $sender, $email, $subject, $body) !== true) { JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } JRequest::setVar('view', 'sent'); $this->display(); }
protected function createEmailBody($subscription, $subject, $authorname, $LastPostUrl, $message, $once) { if ($subscription) { $msg1 = $this->get('parent') ? JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION1') : JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION1_CAT'); $msg2 = $this->get('parent') ? JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION2') : JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION2_CAT'); } else { $msg1 = JText::_('COM_KUNENA_POST_EMAIL_MOD1'); $msg2 = JText::_('COM_KUNENA_POST_EMAIL_MOD2'); } $msg = $msg1 . " " . $this->_config->board_title . "\n\n"; // DO NOT REMOVE EXTRA SPACE, JMailHelper::cleanBody() removes "Subject:" from the message body $msg .= JText::_('COM_KUNENA_MESSAGE_SUBJECT') . " : " . $subject . "\n"; $msg .= JText::_('COM_KUNENA_GEN_CATEGORY') . " : " . $this->parent->catname . "\n"; $msg .= JText::_('COM_KUNENA_VIEW_POSTED') . " : " . $authorname . "\n\n"; $msg .= "URL : {$LastPostUrl}\n\n"; if ($this->_config->mailfull == 1) { $msg .= JText::_('COM_KUNENA_GEN_MESSAGE') . " :\n-----\n"; $msg .= $message; $msg .= "\n-----\n\n"; } $msg .= $msg2 . "\n"; if ($subscription && $once) { if ($this->get('parent')) { $msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_READ') . "\n"; } else { $msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION_MORE_SUBSCRIBE') . "\n"; } } $msg .= "\n"; $msg .= JText::_('COM_KUNENA_POST_EMAIL_NOTIFICATION3') . "\n"; return JMailHelper::cleanBody($msg); }
function mail_notification($subscription) { if (in_array(15, $subscription->courses)) { jimport('joomla.mail.helper'); $JLMS_CONFIG =& JLMSFactory::getConfig(); $SiteName = $JLMS_CONFIG->get('sitename'); $MailFrom = $JLMS_CONFIG->get('mailfrom'); $FromName = $JLMS_CONFIG->get('fromname'); JLoader::import('autoresponder_spu', JPATH_SITE, ''); $subject = AutoResponder::getSubject(); $body = AutoResponder::getBody(); $body = sprintf($body); $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $from = $SiteName . ' ' . $FromName; $sender = JMailHelper::cleanAddress($MailFrom); $email = JMailHelper::cleanAddress(JRequest::getVar('x_email', '')); $user =& JFactory::getUser(); $name = explode(' ', $user->name); $firstname = isset($name[0]) && $name[0] ? $name[0] : $user->name; $body = str_replace('{firstname}', $firstname, $body); if (JUtility::sendMail($from, $sender, $email, $subject, $body, true) !== true) { JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); } } }
/** * Helper wrapper method for cleanBody * * @param string $body email body string. * * @return string Cleaned email body string. * * @see JMailHelper::cleanBody() * @since 3.4 */ public function cleanBody($body) { return JMailHelper::cleanBody($body); }
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { // Check for request forgeries Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN')); $timeout = Session::get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 20) { throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } $SiteName = Config::get('sitename'); $MailFrom = Config::get('mailfrom'); $FromName = Config::get('fromname'); $link = MailtoHelper::validateHash(Request::getCMD('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } // An array of email headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { App::abort(403, ''); } } } // Free up memory unset($headers, $fields); $email = Request::getString('mailto', '', 'post'); $sender = Request::getString('sender', '', 'post'); $from = Request::getString('from', '', 'post'); $subject_default = Lang::txt('COM_MAILTO_SENT_BY', $sender); $subject = Request::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $email); Notify::warning($error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $from); Notify::warning($error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = Lang::txt('COM_MAILTO_EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true) { throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } Request::setVar('view', 'sent'); $this->display(); }
$list_email_administrator = $MailFrom; } $emails = @explode(',', $list_email_administrator); $subject = JText::_('AC_REPORT_THIS_LISTING') . " (" . $SiteName . ")"; // Build the message to send $msg = JText::_('AUP_EMAIL_MSG_INVITE'); $body = sprintf($msg, $SiteName, $sender, $link) . " \n" . $report; $body = JText::_('AC_USER_REPORTED_ARTICLE') . " \n"; $body .= JText::_('AC_NAME') . ": " . $reportname . " \n"; $body .= JText::_('AC_EMAIL') . ": " . $reportemail . " \n"; $body .= JText::_('AC_REPORT') . ": " . $report . " \n"; $body .= JText::_('AC_COMPONENT') . ": " . $type . " \n"; $body .= JText::_('AC_ID') . ": " . $id . " \n"; // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); foreach ($emails as $email) { if (JMailHelper::isEmailAddress($email)) { $mailer =& JFactory::getMailer(); $mailer->setSender(array($MailFrom, $FromName)); $mailer->setSubject($subject); $mailer->setBody($body); $mailer->addRecipient($email); if ($mailer->Send() === true) { $success = true; } } } if ($success) { echo JText::_('AC_THANKS4UREPORT'); } else {
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { // Check for request forgeries JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $session = JFactory::getSession(); $db = JFactory::getDbo(); $timeout = $session->get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 20) { JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } jimport('joomla.mail.helper'); $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $link = MailtoHelper::validateHash(JRequest::getCMD('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } // An array of email headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $subject_default = JText::sprintf('COM_MAILTO_SENT_BY', $sender); $subject = JRequest::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = JText::_('COM_MAILTO_EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JUtility::sendMail($from, $sender, $email, $subject, $body) !== true) { JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } JRequest::setVar('view', 'sent'); $this->display(); }
/** * Rates an event * * @throws Exception if user is not logged in * @return void / redirect */ public function rate() { // Check if user is logged in if (JFactory::getUser()->id == 0) { throw new Exception("COM_MATUKIO_NO_ACCESS"); } $msg = JText::_("COM_MATUKIO_RATING_SUCCESSFULL"); $mainframe = JFactory::getApplication(); jimport('joomla.mail.helper'); $my = JFactory::getuser(); $database = JFactory::getDBO(); $cid = JFactory::getApplication()->input->getInt('cid', 0); $grade = JFactory::getApplication()->input->getInt('grade', 0); $text = JFactory::getApplication()->input->get('text', ''); $text = str_replace(array("\"", "\\'"), "", $text); $text = JMailHelper::cleanBody($text); $database->setQuery("UPDATE #__matukio_bookings SET grade='" . $grade . "', comment='" . $text . "' WHERE semid='" . $cid . "' AND userid='" . $my->id . "'"); if (!$database->execute()) { JError::raiseError(500, $database->getError()); exit; } $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid='" . $cid . "'"); $rows = $database->loadObjectList(); $zaehler = 0; $wertung = 0; foreach ($rows as $row) { if ($row->grade > 0) { $wertung = $wertung + $row->grade; $zaehler++; } } if ($zaehler > 0) { $geswert = round($wertung / $zaehler); } else { $geswert = 0; } $database->setQuery("UPDATE #__matukio SET grade='{$geswert}' WHERE id='{$cid}'"); if (!$database->execute()) { JError::raiseError(500, $database->getError()); $msg = "COM_MATUKIO_RATING_FAILED " . $database->getError(); } if (MatukioHelperSettings::getSettings('sendmail_owner', 1) > 0) { $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid='{$cid}' AND userid='{$my->id}'"); $buchung = $database->loadObject(); // Load event (use model function) $emodel = JModelLegacy::getInstance('Event', 'MatukioModel'); $row = $emodel->getItem($cid); $publisher = JFactory::getuser($row->publisher); $body = "\n<head>\n<style type=\"text/css\">\n<!--\nbody {\nfont-family: Verdana, Tahoma, Arial;\nfont-size:12pt;\n}\n-->\n</style></head><body>"; $body .= "<p><div style=\"font-size: 10pt\">" . JTEXT::_('COM_MATUKIO_RECEIVED_RATING') . "</div>"; $body .= "<p><div style=\"font-size: 10pt\">" . JTEXT::_('COM_MATUKIO_RATING') . ":</div>"; $htxt = str_replace('SEM_POINTS', $grade, JTEXT::_('COM_MATUKIO_SEM_POINTS_6')); $body .= "<div style=\"border: 1px solid #A0A0A0; width: 100%; padding: 5px;\">" . $htxt . "</div>"; $body .= "<p><div style=\"font-size: 10pt\">" . JTEXT::_('COM_MATUKIO_COMMENT') . ":</div>"; $body .= "<div style=\"border: 1px solid #A0A0A0; width: 100%; padding: 5px;\">" . htmlspecialchars($text) . "</div>"; $body .= "<p><div style=\"font-size: 10pt\">" . JTEXT::_('COM_MATUKIO_AVARAGE_SCORE') . ":</div>"; $htxt = str_replace('SEM_POINTS', $geswert, JTEXT::_('COM_MATUKIO_SEM_POINTS_6')); $body .= "<div style=\"border: 1px solid #A0A0A0; width: 100%; padding: 5px;\">" . $htxt . "</div>"; $body .= "<p>" . MatukioHelperUtilsEvents::getEmailBody($row, $buchung, $my); $sender = $mainframe->getCfg('fromname'); $from = $mainframe->getCfg('mailfrom'); $replyname = $my->name; $replyto = $my->email; $email = $publisher->email; $subject = JTEXT::_('COM_MATUKIO_EVENT'); if ($row->semnum != "") { $subject .= " " . $row->semnum; } $subject .= ": " . $row->title; $subject = JMailHelper::cleanSubject($subject); $mailer = JFactory::getMailer(); $mailer->sendMail($from, $sender, $email, $subject, $body, 1, null, null, null, $replyto, $replyname); } $link = "index.php?option=com_matukio&tmpl=component&s=" . MatukioHelperUtilsBasic::getRandomChar() . "&view=rateevent&cid=" . $cid; $this->setRedirect($link, $msg); }