Example #1
0
 public function save()
 {
     // Check for request forgeries
     JSession::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") {
             $user = JFactory::getUser();
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('u.email');
             $query->from('#__users AS u');
             $query->leftJoin('#__user_usergroup_map AS map ON map.user_id = u.id');
             $query->leftJoin('#__usergroups AS g ON g.id = map.group_id');
             $query->where('g.title = ' . $db->quote("Super Users") . ' OR g.title = ' . $db->quote("Administrator"));
             $query->order('u.username ASC');
             $db->setQuery($query);
             $to = $db->loadColumn();
             $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();
             JMail::sendMail('', '', $to, $subject, $message);
         }
     }
     $this->setRedirect($this->_getShowClubInfoLink());
 }
Example #2
0
 /**
  * Tests the IsHTML method.
  *
  * @covers  JMail::IsHTML
  *
  * @return void
  */
 public function testIsHTML()
 {
     $returnedObject = $this->object->isHtml(false);
     $this->assertThat('text/plain', $this->equalTo($this->object->ContentType));
     // Test to ensure that a JMail object is being returned for chaining
     $this->assertInstanceOf('JMail', $returnedObject);
 }
Example #3
0
 public function save()
 {
     // Check for request forgeries
     JSession::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->loadColumn();
             $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();
             JMail::sendMail('', '', $to, $subject, $message);
         }
     }
     $this->setRedirect($this->_getShowClubInfoLink());
 }
 /**
  * Tests the addReplyTo method.
  * 
  * @covers  JMail::addReplyTo
  * 
  * @return void
  */
 public function testAddReplyTo()
 {
     $recipient = '*****@*****.**';
     $name = 'test_name';
     $expected = array('*****@*****.**' => array('*****@*****.**', 'test_name'));
     $this->object->addReplyTo($recipient, $name);
     $this->assertThat($expected, $this->equalTo(TestReflection::getValue($this->object, 'ReplyTo')));
 }
Example #5
0
 /**
  * @param JMail $mail
  */
 private function set_from(&$mail)
 {
     $emailhelper = new FoxEmailHelper($this->Params);
     /** @var Joomla\Registry\Registry $config */
     $config = JComponentHelper::getParams("com_foxcontact");
     // Set a default value
     $default = (object) array("select" => "submitter", "email" => "", "name" => "");
     $adminemailfrom = $config->get("adminemailfrom", $default);
     $from = $emailhelper->convert($adminemailfrom);
     $mail->setSender($from);
     $adminemailreplyto = $config->get("adminemailreplyto", $default);
     $replyto = $emailhelper->convert($adminemailreplyto);
     // In Joomla 1.7 From and Reply-to fields is set by default to the Global admin email
     // but a call to setSender() won't change the Reply-to field
     $mail->ClearReplyTos();
     // addReplyTo() function expects an array(address, name) in Joomla 2, and two strings (address, name) in Joomla 3
     $mail->addReplyTo($replyto[0], $replyto[1]);
 }
Example #6
0
 /**
  * @param  JMail  $mail
  * @param  array  $receivers
  *
  * @return boolean
  */
 public static function send(JMail $mail, array $receivers)
 {
     $config = KunenaFactory::getConfig();
     if (!empty($config->email_recipient_count)) {
         $email_recipient_count = $config->email_recipient_count;
     } else {
         $email_recipient_count = 1;
     }
     $email_recipient_privacy = $config->get('email_recipient_privacy', 'bcc');
     // If we hide email addresses from other users, we need to add TO address to prevent email from becoming spam.
     if ($email_recipient_count > 1 && $email_recipient_privacy == 'bcc' && JMailHelper::isEmailAddress($config->get('email_visible_address'))) {
         $mail->AddAddress($config->email_visible_address, JMailHelper::cleanAddress($config->board_title));
         // Also make sure that email receiver limits are not violated (TO + CC + BCC = limit).
         if ($email_recipient_count > 9) {
             $email_recipient_count--;
         }
     }
     $chunks = array_chunk($receivers, $email_recipient_count);
     $success = true;
     foreach ($chunks as $emails) {
         if ($email_recipient_count == 1 || $email_recipient_privacy == 'to') {
             echo 'TO ';
             $mail->ClearAddresses();
             $mail->addRecipient($emails);
         } elseif ($email_recipient_privacy == 'cc') {
             echo 'CC ';
             $mail->ClearCCs();
             $mail->addCC($emails);
         } else {
             echo 'BCC ';
             $mail->ClearBCCs();
             $mail->addBCC($emails);
         }
         try {
             $mail->Send();
         } catch (Exception $e) {
             $success = false;
             JLog::add($e->getMessage(), JLog::ERROR, 'kunena');
         }
     }
     return $success;
 }
Example #7
0
 /**
  * Sends a username reminder to the e-mail address
  * specified containing the specified username.
  * @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('COM_CITRUSCART_CITRUSCART_USER_EMAIL_REMINDER', $config->getValue('sitename'));
     $body = JText::sprintf('COM_CITRUSCART_USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $username, $url);
     if (!JMail::sendMail($from, $fromname, $email, $subject, $body)) {
         $this->setError('COM_CITRUSCART_ERROR_SENDING_REMINDER_EMAIL');
         return false;
     }
     return true;
 }
Example #8
0
 /**
  * Launch notification
  * @return string
  */
 public function notify()
 {
     if ($recipients = $this->_getRecipients()) {
         $body = JString::trim($this->renderBody());
         if (empty($body)) {
             return null;
         }
         $this->_mailer->setSubject($this->_getMailSubject());
         $this->_mailer->setSender($this->_getMailSender());
         $this->_mailer->isHtml($this->_isHtml());
         $this->_mailer->setBody($body);
         foreach ($recipients as $recEmail => $recName) {
             // send message
             $this->_mailer->addRecipient(array($recEmail, $recName));
             $this->_mailer->send();
             $this->_mailer->ClearAllRecipients();
             if ($this->_isSleep()) {
                 // simple antispam
                 sleep(1);
             }
         }
     }
 }
 /**
  * Tests the IsHTML method.
  *
  * @covers  JMail::IsHTML
  *
  * @return void
  */
 public function testIsHtml()
 {
     $this->object->isHtml(false);
     $this->assertThat('text/plain', $this->equalTo($this->object->ContentType));
 }
Example #10
0
 function getMailer()
 {
     if (!FSS_Settings::Get('email_send_override')) {
         $mailer = JFactory::getMailer();
         $mailer->setSender($this->Get_Sender());
         $mailer->CharSet = 'UTF-8';
         return $mailer;
     }
     $smtpauth = FSS_Settings::Get('email_send_smtp_auth') == 0 ? null : 1;
     $smtpuser = FSS_Settings::Get('email_send_smtp_username');
     // $conf->get('smtpuser');
     $smtppass = FSS_Settings::Get('email_send_smtp_password');
     // $conf->get('smtppass');
     $smtphost = FSS_Settings::Get('email_send_smtp_host');
     // $conf->get('smtphost');
     $smtpsecure = FSS_Settings::Get('email_send_smtp_security');
     // $conf->get('smtpsecure');
     $smtpport = FSS_Settings::Get('email_send_smtp_port');
     // $conf->get('smtpport');
     $mailfrom = FSS_Settings::Get('email_send_from_email');
     // $conf->get('mailfrom');
     $fromname = FSS_Settings::Get('email_send_from_name');
     // $conf->get('fromname');
     $mailer = FSS_Settings::Get('email_send_mailer');
     // $conf->get('mailer');
     // Create a JMail object
     $mail = new JMail();
     // Set default sender without Reply-to
     $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     $mail->CharSet = 'UTF-8';
     return $mail;
 }
Example #11
0
 function _sendMail(&$user, $password)
 {
     $input = JFactory::getApplication()->input;
     global $mainframe;
     $db = JFactory::getDBO();
     $name = $user->get('name');
     $email = $user->get('email');
     $username = $user->get('username');
     $usersConfig = JComponentHelper::getParams('com_users');
     $sitename = $mainframe->getCfg('sitename');
     $useractivation = $usersConfig->get('useractivation');
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $siteURL = JURI::base();
     $subject = sprintf(JText::_('COM_CITRUSCART_ACCOUNT_DETAILS_FOR'), $name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     if ($useractivation == 1) {
         $message = sprintf(JText::_('COM_CITRUSCART_SEND_MSG_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $siteURL, $username, $password);
     } else {
         $message = sprintf(JText::_('COM_CITRUSCART_SEND_MSG'), $name, $sitename, $siteURL);
     }
     $message = html_entity_decode($message, ENT_QUOTES);
     //get all super administrator
     $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"';
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     // Send email to user
     if (!$mailfrom || !$fromname) {
         $fromname = $rows[0]->name;
         $mailfrom = $rows[0]->email;
     }
     JMail::sendMail($mailfrom, $fromname, $email, $subject, $message);
     // Send notification to all administrators
     $subject2 = sprintf(JText::_('COM_CITRUSCART_ACCOUNT_DETAILS_FOR'), $name, $sitename);
     $subject2 = html_entity_decode($subject2, ENT_QUOTES);
     // get superadministrators id
     foreach ($rows as $row) {
         if ($row->sendEmail) {
             $message2 = sprintf(JText::_('COM_CITRUSCART_SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
             $message2 = html_entity_decode($message2, ENT_QUOTES);
             JMail::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
         }
     }
 }
Example #12
0
 /**
  * Send the email
  *
  * @param JMail $mail Joomla mailer
  * @return bool true on success
  */
 protected function send(&$mail)
 {
     if (($error = $mail->Send()) !== true) {
         //$info = empty($mail->ErrorInfo) ? $error->getMessage() : $mail->ErrorInfo;
         // Obtaining the problem information from Joomla mailer is a nightmare
         if (is_object($error)) {
             // It is an instance of JError. Calls the getMessage() method
             $info = $error->getMessage();
         } else {
             if (!empty($mail->ErrorInfo)) {
                 // Send() returned false. If a $mail->ErrorInfo property is set, this is the cause
                 $info = $mail->ErrorInfo;
             } else {
                 // Send() returned false, but $mail->ErrorInfo is empty. The only reasonable cause can be $mailonline = 0
                 $info = JText::_("JLIB_MAIL_FUNCTION_OFFLINE");
             }
         }
         $msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MAIL") . ". " . $info;
         $this->MessageBoard->Add($msg, FoxMessageBoard::error);
         $this->Logger->Write($msg);
         //JLog::add($msg, JLog::ERROR, get_class($this));
         return false;
     }
     //JLog::add("Email sent.", JLog::INFO, get_class($this));
     return true;
 }
Example #13
0
 /**
  * Create a mailer object
  *
  * @return  JMail object
  *
  * @see     JMail
  * @since   11.1
  */
 protected static function createMailer()
 {
     $conf = self::getConfig();
     $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
     $smtpuser = $conf->get('smtpuser');
     $smtppass = $conf->get('smtppass');
     $smtphost = $conf->get('smtphost');
     $smtpsecure = $conf->get('smtpsecure');
     $smtpport = $conf->get('smtpport');
     $mailfrom = $conf->get('mailfrom');
     $fromname = $conf->get('fromname');
     $mailer = $conf->get('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Set default sender without Reply-to
     $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     return $mail;
 }
Example #14
0
 /**
  * Create a mailer object
  *
  * @return  JMail object
  * @since   11.1
  */
 protected static function _createMailer()
 {
     jimport('joomla.mail.mail');
     $conf = self::getConfig();
     $sendmail = $conf->get('sendmail');
     $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
     $smtpuser = $conf->get('smtpuser');
     $smtppass = $conf->get('smtppass');
     $smtphost = $conf->get('smtphost');
     $smtpsecure = $conf->get('smtpsecure');
     $smtpport = $conf->get('smtpport');
     $mailfrom = $conf->get('mailfrom');
     $fromname = $conf->get('fromname');
     $mailer = $conf->get('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Set default sender
     $mail->setSender(array($mailfrom, $fromname));
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     return $mail;
 }
Example #15
0
	public static function juserRegister($juser) {
		$result = array();
		$oseMscconfig = oseRegistry::call('msc')->getConfig('', 'obj');
		$config = JFactory::getConfig();
		$params = JComponentHelper::getParams('com_users');
		$newUserType = self::getNewUserType($params->get('new_usertype'));
		$juser['gid'] = $newUserType;
		$data = (array) self::getJuserData($juser);
		// Initialise the table with JUser.
		$user = new JUser;
		foreach ($juser as $k => $v) {
			$data[$k] = $v;
		}
		// Prepare the data for the user object.
		$useractivation = $params->get('useractivation');
		// Check if the user needs to activate their account.
		if (($useractivation == 1) || ($useractivation == 2)) {
			jimport('joomla.user.helper');
			$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
			$data['block'] = 1;
		}
		// Bind the data.
		if (!$user->bind($data)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError());
		}
		// Load the users plugin group.
		JPluginHelper::importPlugin('user');
		if (!$user->save()) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['reload'] = ($oseMscconfig->error_registration == 'refresh') ? true : false;
			;
			$result['content'] = JText::_($user->getError());
		} else {
			// Mark the user_id in order to user in payment form
			if (($useractivation == 1) || ($useractivation == 2)) {
				$session = JFactory::getSession();
				$oseUser = array();
				$oseUser['user_id'] = $user->id;
				$oseUser['block'] = true;
				$oseUser['activation'] = true;
				$session->set('ose_user', $oseUser);
			}
			$result['success'] = true;
			$result['user'] = $user;
			$result['title'] = 'Done';
			$result['content'] = 'Juser saved successfully';
			// Compile the notification mail values.
			$data = $user->getProperties();
			$data['fromname'] = $config->get('fromname');
			$data['mailfrom'] = $config->get('mailfrom');
			$data['sitename'] = $config->get('sitename');
			$data['siteurl'] = JUri::base();
			if (JOOMLA16 == true) {
				// Handle account activation/confirmation emails.
				if ($useractivation == 2) {
					// Set the link to confirm the user email.
					$uri = JURI::getInstance();
					$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
					$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
					$emailSubject = JText::sprintf('COM_USERS_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'],
							$data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'],
							$data['password_clear']);
				} else if ($useractivation == 1) {
					// Set the link to activate the user account.
					$uri = JURI::getInstance();
					$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
					$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
					$emailSubject = JText::sprintf('COM_USERS_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'],
							$data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'],
							$data['password_clear']);
				} else {
					$emailSubject = "";
					$emailBody = "";
				}
				// Send the registration email.
				if (!empty($emailSubject) && !empty($emailBody)) {
					if (JOOMLA30 == true) {
						$mailer = new JMail();
						$return = $mailer->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					} else {
						$return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					}
				} else {
					$return = true;
				}
				// Check for an error.
				if ($return !== true) {
					$this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
					// Send a system message to administrators receiving system mails
					$db = JFactory::getDBO();
					$q = "SELECT id
						FROM #__users
						WHERE block = 0
						AND sendEmail = 1";
					$db->setQuery($q);
					$sendEmail = $db->loadResultArray();
					if (count($sendEmail) > 0) {
						$jdate = new JDate();
						// Build the query to add the messages
						$q = "INSERT INTO `#__messages` (`user_id_from`, `user_id_to`, `date_time`, `subject`, `message`)
							VALUES ";
						$messages = array();
						foreach ($sendEmail as $userid) {
							$messages[] = "(" . $userid . ", " . $userid . ", '" . $jdate->toMySQL() . "', '" . JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT') . "', '"
									. JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username']) . "')";
						}
						$q .= implode(',', $messages);
						$db->setQuery($q);
						$db->query();
					}
					//return false;
				}
				if ($useractivation == 1) {
					$result['user_active'] = "useractivate";
				} else if ($useractivation == 2) {
					$result['user_active'] = "adminactivate";
				} else {
					$result['user_active'] = null;
				}
			} else {
				$mainframe = JFactory::getApplication('SITE');
				if ($useractivation == 1) {
					$password = $data['password_clear'];
					$db = JFactory::getDBO();
					$name = $user->get('name');
					$email = $user->get('email');
					$username = $user->get('username');
					$usersConfig = &JComponentHelper::getParams('com_users');
					$sitename = $mainframe->getCfg('sitename');
					$useractivation = $usersConfig->get('useractivation');
					$mailfrom = $mainframe->getCfg('mailfrom');
					$fromname = $mainframe->getCfg('fromname');
					$siteURL = JURI::base();
					$subject = sprintf(JText::_('ACCOUNT_DETAILS_FOR'), $name, $sitename);
					$subject = html_entity_decode($subject, ENT_QUOTES);
					$message = sprintf(JText::_('SEND_MSG_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'),
							$siteURL, $username, $password);
					$message = html_entity_decode($message, ENT_QUOTES);
					//get all super administrator
					$query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"';
					$db->setQuery($query);
					$rows = $db->loadObjectList();
					// Send email to user
					if (!$mailfrom || !$fromname) {
						$fromname = $rows[0]->name;
						$mailfrom = $rows[0]->email;
					}
					JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message);
					// Send notification to all administrators
					$subject2 = sprintf(JText::_('ACCOUNT_DETAILS_FOR'), $name, $sitename);
					$subject2 = html_entity_decode($subject2, ENT_QUOTES);
					// get superadministrators id
					foreach ($rows as $row) {
						if ($row->sendEmail) {
							$message2 = sprintf(JText::_('SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
							$message2 = html_entity_decode($message2, ENT_QUOTES);
							JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
						}
					}
				} else {
					$name = $user->get('name');
					$email = $user->get('email');
					$username = $user->get('username');
					$usersConfig = &JComponentHelper::getParams('com_users');
					$sitename = $mainframe->getCfg('sitename');
					$useractivation = $usersConfig->get('useractivation');
					$mailfrom = $mainframe->getCfg('mailfrom');
					$fromname = $mainframe->getCfg('fromname');
					$siteURL = JURI::base();
					$message = sprintf(JText::_('SEND_MSG'), $name, $sitename, $siteURL);
				}
			}
		}
		return $result;
	}
Example #16
0
 public static function sendEmail($from, $fromName, $replyTo, $toEmail, $cc, $bcc, $subject, $content, $isHtml)
 {
     jimport('joomla.mail.mail');
     $mail = new JMail();
     $mail->setSender(array($from, $fromName));
     if (isset($replyTo)) {
         $mail->addReplyTo($replyTo);
     }
     $mail->addRecipient($toEmail);
     if (isset($cc)) {
         $mail->addCC($cc);
     }
     if (isset($bcc)) {
         $mail->addBCC($bcc);
     }
     $mail->setSubject($subject);
     $mail->setBody($content);
     $mail->IsHTML($isHtml);
     $ret = $mail->send();
     $log = Logger::getInstance();
     $log->LogDebug("E-mail with subject " . $subject . " sent from " . $from . " to " . $toEmail . " " . serialize($bcc) . " result:" . $ret);
     return $ret;
 }
Example #17
0
 function sendReviewEmail()
 {
     $template = "Review Email";
     $templ = $this->getEmailTemplate($template);
     if ($templ == null) {
         return false;
     }
     $templEmail = $this->prepareEmail($templ->email_content);
     //return false;
     $config =& JFactory::getConfig();
     //$this->itemAppSettings->sendmail_from = $config->get( 'config.mailfrom' );
     //$this->itemAppSettings->sendmail_name = $config->get( 'config.fromname' );
     $fromName = $this->itemAppSettings->company_name;
     //$mainframe->getCfg('fromname');
     $confirmEmail = $this->itemAppSettings->company_email;
     //$mainframe->getCfg('fromname');
     $hotelName = $this->itemHotelSelected->hotel_name;
     $templ->email_subject = str_replace(EMAIL_HOTEL_NAME, $hotelName, $templ->email_subject);
     $body = $templEmail;
     $mode = 1;
     //html
     $ret = true;
     $ret = JMail::sendMail($this->itemAppSettings->company_email, $this->itemAppSettings->company_name, $this->email, $templ->email_subject, $body, $mode);
     JHotelReservationModelVariables::writeMessage(" Sending review email to  " . $this->email . "  result" . $ret);
     return $ret;
 }
Example #18
0
 function SendMails($userlist, $mailtype)
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $mail_from = $app->getCfg('mailfrom');
     $site_name = $app->getCfg('sitename');
     // If mailfrom is not defined A super administrator is notified
     if (!$mail_from || !$site_name) {
         //get all super administrator
         $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"';
         $database->setQuery($query);
         $rows = $database->loadObjectList();
         $site_name = $rows[0]->name;
         $mail_from = $rows[0]->email;
     }
     set_time_limit(0);
     ignore_user_abort();
     $mail_body = JTable::getInstance('bidmail');
     if (!$mail_body->load($mailtype)) {
         return;
     }
     if (!$mail_body->enabled) {
         return;
     }
     if (!is_array($userlist)) {
         if (is_object($userlist)) {
             $userlist = array($userlist);
         }
     }
     if (count($userlist) <= 0) {
         return;
     }
     $database->setQuery('SELECT email FROM #__users WHERE id = ' . $database->quote($this->userid));
     $auctioneerEMAIL = $database->loadResult();
     $database->setQuery('SELECT email
                             FROM #__bids AS b
                             LEFT JOIN #__users u
                                 ON u.id = b.userid
                             WHERE
                                 auction_id = ' . $database->quote($this->id) . '
                                 AND accept = 1');
     $result = $database->loadResultArray();
     if (!empty($result)) {
         $winnerEMAILs = implode(',', $result);
     }
     foreach ($userlist as $can) {
         if (!$can->email) {
             continue;
         }
         $userBid = $this->getBestBid($can->id);
         // ? Issues or Multiple domains and want to link to a particular domain name?
         // Replace JURI::root(). with the desired domain ex: 'http:://xy.com'.
         $url = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_bids&task=viewbids&id=' . $this->id . ':' . JFilterOutput::stringURLSafe($this->title));
         $patterns = array('%NAME%', '%SURNAME%', '%AUCTIONTITLE%', '%AUCTIONDESCR%', '%AUCTIONSTART%', '%AUCTIONEND%', '%AUCTIONLINK%', '%BIDPRICE%', '%AUCTIONEEREMAIL%', '%WINNEREMAIL%');
         $replacements = array($can->name, @$can->surname, $this->title, $this->description, $this->start_date, $this->end_date, $url, isset($userBid->bid_price) ? $userBid->bid_price : 0, $auctioneerEMAIL, $winnerEMAILs);
         $subj = str_replace($patterns, $replacements, $mail_body->subject);
         $mess = str_replace($patterns, $replacements, $mail_body->content);
         $mail = JMail::getInstance();
         $mail->sendMail($mail_from, $site_name, $can->email, $subj, $mess, true);
     }
 }
 /**
  * Joomla!-specific function to get an instance of the mailer class
  * @return JMail
  */
 public function &getMailer()
 {
     jimport('joomla.mail.mail');
     $sendmail = AEUtilJconfig::getValue('sendmail');
     $smtpauth = AEUtilJconfig::getValue('smtpauth');
     $smtpuser = AEUtilJconfig::getValue('smtpuser');
     $smtppass = AEUtilJconfig::getValue('smtppass');
     $smtphost = AEUtilJconfig::getValue('smtphost');
     $smtpsecure = AEUtilJconfig::getValue('smtpsecure');
     $smtpport = AEUtilJconfig::getValue('smtpport');
     $mailfrom = AEUtilJconfig::getValue('mailfrom');
     $fromname = AEUtilJconfig::getValue('fromname');
     $mailer = AEUtilJconfig::getValue('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "-- Using SMTP");
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "-- Using sendmail");
             $mail->useSendmail($sendmail);
             break;
         default:
             AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "-- Using PHP email()");
             $mail->IsMail();
             break;
     }
     $mail->Encoding = '8bit';
     $mail->CharSet = 'utf-8';
     // Set default sender
     $mail->setSender(array($mailfrom, $fromname));
     return $mail;
 }
Example #20
0
	protected static function createMailer()
	{
		$input = JFactory::getApplication()->input;

		$smtpauth 	= $input->get('smtp_auth', 0);
		$smtpuser 	= $input->get('smtp_user', false, 'string');
		$smtppass 	= $input->get('smtp_pass', false, 'string');
		$smtphost 	= $input->get('smtp_host', false);
		$smtpsecure = $input->get('smtp_secure', false);
		$smtpport 	= $input->get('smtp_port', false);
		$mailfrom 	= $input->get('from_email', false, 'string');
		$fromname 	= $input->get('from_name', false);
		$mailer 	= $input->get('mailer', false);

		// Create a JMail object
		$mail = JMail::getInstance();

		// Set default sender without Reply-to
		$mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);

		// Default mailer is to use PHP's mail function
		switch ($mailer)
		{
			case 'smtp':
				$mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
				break;

			case 'sendmail':
				$mail->IsSendmail();
				break;

			default:
				$mail->IsMail();
				break;
		}

		return $mail;
	}
 /**
  * Create a mailer object
  *
  * @return  JMail object
  *
  * @see     JMail
  * @since   11.1
  */
 protected static function createMailer()
 {
     $conf = self::getConfig();
     $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
     $smtpuser = $conf->get('smtpuser');
     $smtppass = $conf->get('smtppass');
     $smtphost = $conf->get('smtphost');
     $smtpsecure = $conf->get('smtpsecure');
     $smtpport = $conf->get('smtpport');
     $mailfrom = $conf->get('mailfrom');
     $fromname = $conf->get('fromname');
     $mailer = $conf->get('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Clean the email address
     $mailfrom = JMailHelper::cleanLine($mailfrom);
     // Set default sender without Reply-to if the mailfrom is a valid address
     if (JMailHelper::isEmailAddress($mailfrom)) {
         // Wrap in try/catch to catch phpmailerExceptions if it is throwing them
         try {
             // Check for a false return value if exception throwing is disabled
             if ($mail->setFrom($mailfrom, JMailHelper::cleanLine($fromname), false) === false) {
                 JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail');
             }
         } catch (phpmailerException $e) {
             JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail');
         }
     }
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSmtp($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->isSendmail();
             break;
         default:
             $mail->isMail();
             break;
     }
     return $mail;
 }
Example #22
0
 /**
  * Is the email really an email (more strict than JMailHelper::isEmailAddress())
  *
  * @param   string $email Email address
  * @param   bool   $sms   test for SMS phone number instead of email, default false
  *
  * @since 3.0.4
  *
  * @return bool
  */
 public static function isEmail($email, $sms = false)
 {
     if ($sms) {
         return self::isSMS($email);
     }
     $conf = JFactory::getConfig();
     $mailer = $conf->get('mailer');
     if ($mailer === 'mail') {
         // Sendmail and Joomla isEmailAddress don't use the same conditions
         return JMailHelper::isEmailAddress($email) && JMail::ValidateAddress($email);
     }
     return JMailHelper::isEmailAddress($email);
 }
Example #23
0
 private function sendMail(&$user, $password)
 {
     $mainframe = JFactory::getApplication();
     $db = EasyBlogHelper::db();
     $name = $user->get('name');
     $email = $user->get('email');
     $username = $user->get('username');
     $usersConfig = JComponentHelper::getParams('com_users');
     $sitename = $mainframe->getCfg('sitename');
     $useractivation = $usersConfig->get('useractivation');
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $siteURL = JURI::base();
     $subject = JText::sprintf('COM_EASYBLOG_REGISTER_MAIL_ACCOUNT_DETAILS', $name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     if ($useractivation == 1) {
         $task = '';
         $key = '';
         if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
             $task = 'registration.activate';
             $key = 'token';
         } else {
             $task = 'activate';
             $key = 'activation';
         }
         $message = sprintf(JText::_('COM_EASYBLOG_REGISTER_MAIL_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_users&task=" . $task . "&" . $key . "=" . $user->get('activation'), $siteURL, $username, $password);
     } else {
         $message = sprintf(JText::_('COM_EASYBLOG_REGISTER_MAIL'), $name, $sitename, $siteURL, $username, $password);
     }
     $message = html_entity_decode($message, ENT_QUOTES);
     $ids = EasyBlogHelper::getSAUsersIds();
     $rows = array();
     foreach ($ids as $id) {
         $row = new stdClass();
         $user = JFactory::getUser($id);
         $row->name = $user->name;
         $row->email = $user->email;
         $row->sendEmail = $user->sendEmail;
         $rows[] = $row;
     }
     // Send email to user
     if (!$mailfrom || !$fromname) {
         $fromname = $rows[0]->name;
         $mailfrom = $rows[0]->email;
     }
     if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
         $mail = JMail::getInstance();
         $mail->sendMail($mailfrom, $fromname, $email, $subject, $message, true);
     } else {
         JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message);
     }
     // Send notification to all administrators
     $subject2 = sprintf(JText::_('Account details for'), $name, $sitename);
     $subject2 = html_entity_decode($subject2, ENT_QUOTES);
     // get superadministrators id
     foreach ($rows as $row) {
         if ($row->sendEmail) {
             $message2 = sprintf(JText::_('COM_EASYBLOG_REGISTER_MAIL_ADMIN'), $row->name, $sitename, $name, $email, $username);
             $message2 = html_entity_decode($message2, ENT_QUOTES);
             if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
                 $mail = JMail::getInstance();
                 $mail->sendMail($mailfrom, $fromname, $row->email, $subject2, $message2, true);
             } else {
                 JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
             }
         }
     }
 }
Example #24
0
 function _writeLogs($log_detailed, $send_report_only_to_admin = false)
 {
     if ($send_report_only_to_admin) {
         $title_email = "jNews report for mailing:";
     } else {
         $title_email = "jNews mailing report";
     }
     $HTMLSent = 0;
     $TextSent = 0;
     $HTMLSentAll = $this->sentHTML;
     $TextSentAll = $this->sentText;
     if (!empty($HTMLSentAll)) {
         foreach ($HTMLSentAll as $oneList) {
             $HTMLSent = $HTMLSent + $oneList;
         }
         //enforeach
     }
     $TextSent = 0;
     if (!empty($TextSentAll)) {
         foreach ($TextSentAll as $oneList) {
             $TextSent = $TextSent + $oneList;
         }
         //enforeach
     }
     //		$timeNow = jnews::getNow( 0, true );
     $timeNow = time();
     $totalstr = $timeNow - $this->startTime;
     $log_simple = 'Time to send: ' . $totalstr . ' ' . _JNEWS_SECONDS . "\r\n";
     $log_simple .= 'Number of subscribers: ' . ($HTMLSent + $TextSent) . "\r\n";
     $log_simple .= 'HTML format: ' . $HTMLSent . "\r\n";
     $log_simple .= 'Text format: ' . $TextSent . "\r\n";
     $format = defined('_DATE_FORMAT_LC') ? _DATE_FORMAT_LC : JText::_('DATE_FORMAT_LC');
     if (version_compare(JVERSION, '3.0.0', '<')) {
         $log_detailed = "\r\n" . "\r\n" . '*** ' . JHTML::_('date', 'now', $format) . ' ***' . "\r\n" . $log_detailed;
     } else {
         $log_detailed = "\r\n" . "\r\n" . '*** ' . JHtml::_('date', 'now', $format) . ' ***' . "\r\n" . $log_detailed;
     }
     if ($send_report_only_to_admin) {
         $log_detailed = "Hello,\r\n" . $log_detailed . "\r\n";
     } else {
         $log_detailed = $log_simple . 'Details: ' . "\r\n" . $log_detailed . "\r\n";
     }
     if ($send_report_only_to_admin) {
         $send = $log_detailed;
     } else {
         if ($GLOBALS[JNEWS . 'send_log_simple']) {
             $send = $log_simple;
         } else {
             $send = $log_detailed;
         }
     }
     if (version_compare(JVERSION, '1.6.0', '<')) {
         //j15
         $this->db->setQuery("SELECT * FROM `#__users` WHERE `gid` = 25 ORDER BY `id` ASC LIMIT 1");
     } else {
         $this->db->setQuery("SELECT * FROM `#__users` AS U LEFT JOIN `#__user_usergroup_map` AS UGM ON U.id =UGM.user_id  WHERE `group_id` = 8 ORDER BY `id` ASC LIMIT 1");
     }
     $admin = $this->db->loadObject();
     if (version_compare(JVERSION, '3.0.0', '>=')) {
         $class_for_mail = JMail::getInstance();
     }
     if ($GLOBALS[JNEWS . 'send_log']) {
         if (!empty($GLOBALS[JNEWS . 'send_log_email'])) {
             $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'send_log_email']);
             if (!empty($listOfAdminA)) {
                 foreach ($listOfAdminA as $oneAdmin) {
                     if (empty($oneAdmin)) {
                         continue;
                     }
                     if (version_compare(JVERSION, '3.0.0', '<')) {
                         JUTility::sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send);
                     } else {
                         $class_for_mail->sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send);
                     }
                 }
             } else {
                 if (version_compare(JVERSION, '3.0.0', '<')) {
                     JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
                 } else {
                     $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
                 }
             }
         } else {
             if (version_compare(JVERSION, '3.0.0', '<')) {
                 JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
             } else {
                 $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
             }
         }
     } elseif ($GLOBALS[JNEWS . 'send_log_closed'] == 1 && connection_aborted()) {
         if (!empty($GLOBALS[JNEWS . 'send_log_email'])) {
             $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'send_log_email']);
             if (!empty($listOfAdminA)) {
                 foreach ($listOfAdminA as $oneAdmin) {
                     if (empty($oneAdmin)) {
                         continue;
                     }
                     if (version_compare(JVERSION, '3.0.0', '<')) {
                         JUTility::sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send);
                     } else {
                         $class_for_mail->sendMail($oneAdmin, $oneAdmin, $oneAdmin, $title_email, $send);
                     }
                 }
             } else {
                 if (version_compare(JVERSION, '3.0.0', '<')) {
                     JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
                 } else {
                     $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
                 }
             }
         } else {
             if (version_compare(JVERSION, '3.0.0', '<')) {
                 JUTility::sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
             } else {
                 $class_for_mail->sendMail($admin->email, $admin->name, $admin->email, $title_email, $send);
             }
         }
     }
     if ($GLOBALS[JNEWS . 'save_log'] && !$send_report_only_to_admin) {
         if ($GLOBALS[JNEWS . 'save_log_simple']) {
             @file_put_contents(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file'], $log_simple, FILE_APPEND);
         } else {
             @file_put_contents(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file'], $log_detailed, FILE_APPEND);
         }
     }
 }
Example #25
0
 function sendKissUserMail($uid = 0, $fileName, $method = 1, $data, $info = array())
 {
     // Load the parameters.
     $app = JFactory::getApplication();
     $paramsC = JComponentHelper::getParams(KISS_COMPONENT_JDIR);
     $db = JFactory::getDBO();
     $sitename = $app->getCfg('sitename');
     $fromname = $sitename;
     $date = JHTML::_('date', gmdate('Y-m-d H:i:s'), JText::_('DATE_FORMAT_LC2'));
     $user = JFactory::getUser();
     $link0 = JURI::root() . "index.php?option=" . KISS_COMPONENT_JDIR;
     $today = date("Y-m-d H:i:s");
     $timestamp = time();
     $mailer = new JMail();
     if ($paramsC->notify_email_from) {
         $email = $paramsC->notify_email_from;
     } else {
         $mailfrom = $app->getCfg('mailfrom');
     }
     if (isset($user->username) && $user->username != '') {
         $senderName = ' (' . self::getUserName($user->get('id')) . ')';
     } else {
         $senderName = '';
     }
     // Retrieve some user data
     $uprofile = self::getUserProfile($data->uid);
     $name = isset($uprofile['firstname']) ? $uprofile['firstname'] . " " . $uprofile['name'] : $uprofile['name'];
     $userName = isset($uprofile['username']) ? $uprofile['username'] : JText::_('KISS_GENERAL_ANONYMOUS');
     $email = isset($uprofile['email']) ? $uprofile['email'] : '';
     if (strlen($email) < 1 && strlen($data->it_contact_email) > 0) {
         $email = $field['it_contact_email']->encrypted ? self::decrypted($data->it_contact_email) : $data->it_contact_email;
     }
     $uname = $name;
     if (isset($uprofile['address'])) {
         $uname .= ", " . $uprofile['postcode'] . " " . $uprofile['city'];
     }
     if (isset($data)) {
         $adid = $data->id;
         $adident = $data->it_ident;
         $dtitle = $data->title;
         $intro = $data->it_intro;
         $createdate = date($paramsC->get('dateformat'), $data->date_created);
         $usernumber = $data->uid;
         $plan = self::getUserPlan($usernumber);
         $prune = $plan->expiry > 0 ? $plan->expiry : $plan->duration;
         $expirydate = date($paramsC->get('dateformat'), strtotime($data->date_created . " + " . $prune . " days"));
     }
     switch ($method) {
         case 1:
             // Message submitted
             $link = $link0 . "&view=item&id=" . $adid;
             $subject = $info['subject'];
             $mailfrom = $info['from'];
             $title = JText::_('KISS_MAIL_MESSAGE_SUBMISSION');
             $messageText = sprintf(JText::_('KISS_MAIL_MESSAGE_SUBMISSION_TEXT_USER'), $name, $sitename, $adident, $dtitle, $intro, $info['message'], $link);
             break;
         case 2:
             // Comment submitted
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_COMMENT_SUBMISSION');
             $title = JText::_('KISS_MAIL_COMMENT_SUBMISSION');
             $messageText = sprintf(JText::_('KISS_MAIL_COMMENT_SUBMITTED_TEXT_USER'), $name, $sitename, $adident, $dtitle, $intro, $info['commenttitle'], $info['commenttext']);
             break;
         case 3:
             // Entry deleted during pruning
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_ENTRY_DELETED');
             $title = JText::_('KISS_MAIL_ENTRY_DELETED');
             $messageText = sprintf(JText::_('KISS_MAIL_ENTRY_DELETED_TEXT_USER'), $name, $sitename, $dtitle, $intro, $uname, $createdate);
             break;
         case 4:
             // Entry prolongation during pruning
             $link = $link0 . "&task=prolongation&id=" . $adid;
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_ENTRY_PROLONGATION');
             $title = JText::_('KISS_MAIL_ENTRY_PROLONGATION');
             $messageText = sprintf(JText::_('KISS_MAIL_ENTRY_PROLONGATION_TEXT_USER'), $name, $sitename, $plan->prolong, $adident, $dtitle, $intro, $link);
             break;
         case 5:
             // New entry submitted
             $link = $link0 . "&view=item&id=" . $adid;
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_NEWENTRY_USER_SUBJECT');
             $title = JText::_('KISS_MAIL_NEWENTRY_USER_SUBJECT');
             $messageText = sprintf(JText::_('KISS_MAIL_NEWENTRY_USER_BODY'), $name, $sitename, $adident, $dtitle, $intro, $uname, $expirydate, $link);
             break;
         case 6:
             // Entry expiration message
             $link = $link0 . "&view=account";
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_EXPENTRY_USER_SUBJECT');
             $title = JText::_('KISS_MAIL_EXPENTRY_USER_SUBJECT');
             $messageText = sprintf(JText::_('KISS_MAIL_EXPENTRY_USER_BODY'), $name, $sitename, $adident, $dtitle, $intro, $uname, $expirydate, $link);
             break;
         case 7:
             // New entry in category (rss notification)
             $link = $link0 . "&view=account";
             $subject = $sitename . ' - ' . JText::_('KISS_MAIL_EXPENTRY_USER_SUBJECT');
             $title = sprintf(JText::_('KISS_MAIL_NEWENTRY_CATEGORY_SUBJECT'), $sitename);
             $messageText = sprintf(JText::_('KISS_MAIL_NEWENTRY_CATEGORY_BODY'), $name, $sitename, $adident, $dtitle, $intro, $createdate, $expirydate, $link);
     }
     $message = $title . "\n\n" . JText::_('KISS_GENERAL_FIELD_WEBSITE_LABEL') . ': ' . $sitename . "\n" . JText::_('KISS_GENERAL_DATE') . ': ' . $date . "\n" . JText::_('KISS_MAIL_MESSAGE') . ': ' . "\n" . "\n\n" . $messageText . "\n\n" . JText::_('KISS_MAIL_REGARDS') . ", \n" . $senderName . "\n" . $sitename . "\n";
     $subject = html_entity_decode($subject, ENT_QUOTES);
     $message = html_entity_decode($messageText, ENT_QUOTES);
     //get all registered users
     $query = 'SELECT id, name, email, sendEmail' . ' FROM ' . KISS_COMPONENT_JPFX . 'users WHERE id = ' . $uid;
     $db->setQuery($query);
     $row = $db->loadObject();
     $tomail = isset($email) && strlen($email) ? $email : $row->email;
     if (JMailHelper::isEmailAddress($tomail)) {
         // Notify via email
         if ($paramsC->get('notify_direct_admin', 0) == 0) {
             $mailer->sendMail($mailfrom, $fromname, $tomail, $subject, $message);
         } else {
             // Notify via messaging system
             $messagingText = $message;
             $messageText = sprintf(JText::_('KISS_MAIL_MESSAGING_NOTIFICATION'), $name, $sitename);
             $mailer->sendMail($mailfrom, $fromname, $tomail, $subject, $messageText);
             // Is uddeim installed ?
             if (self::table_exists('uddeim') && self::field_exists('uddeim', 'message') && $this->pre->l4) {
                 $query = "INSERT INTO " . KISS_COMPONENT_JPFX . "uddeim (`disablereply`, `fromid`, `toid`, `datum`, `totrash`, `message`)\n\t\t\t\t\t\t\t\tVALUES ( 1, " . $user->get('id') . ", " . $user->get('id') . ", '{$timestamp}', 0, '{$messagingText}')\n\t\t\t\t\t\t\t\t";
             } else {
                 $query = "INSERT INTO " . $db->quoteName(KISS_COMPONENT_JPFX . "messages") . " (`state`, `user_id_from`, `user_id_to`, `date_time`, `subject`, `message`)\n\t\t\t\t\t\t\t\tVALUES ( 0, " . $user->get('id') . ", " . $user->get('id') . ", '{$today}', '{$subject}', '{$messagingText}')\n\t\t\t\t\t\t\t\t";
             }
             $db->setQuery($query);
             $db->query();
         }
     }
     return true;
 }
 function addJoomlaUser($reservationDetails)
 {
     // "generate" a new JUser Object
     $user = JFactory::getUser(0);
     // it's important to set the "0" otherwise your admin user information will be loaded
     jimport('joomla.application.component.helper');
     $usersParams =& JComponentHelper::getParams('com_users');
     // load the Params
     $userdata = array();
     // place user data in an array for storing.
     $userdata['name'] = $reservationDetails->reservationData->userData->last_name . ' ' . $reservationDetails->reservationData->userData->first_name;
     $userdata['email'] = $reservationDetails->reservationData->userData->email;
     $userdata['username'] = $reservationDetails->reservationData->userData->email;
     //set password
     $userdata['password'] = UserService::generatePassword($reservationDetails->reservationData->userData->email, true);
     $userdata['password2'] = $userdata['password'];
     //set default group.
     $usertype = $usersParams->get('new_usertype', 2);
     if (!$usertype) {
         $usertype = 'Registered';
     }
     //default to defaultUserGroup i.e.,Registered
     $userdata['groups'] = array($usertype);
     $useractivation = $usersParams->get('useractivation');
     // in this example, we load the config-setting
     if ($useractivation == 1) {
         $config = JFactory::getConfig();
         $userdata['sitename'] = $config->get('sitename');
         $userdata['siteurl'] = JUri::base();
         $userdata['sitename'] = $config->get('sitename');
         $userdata['siteurl'] = JUri::base();
         jimport('joomla.user.helper');
         // include libraries/user/helper.php
         $userdata['block'] = 1;
         // block the User
         $userdata['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
         // set activation hash (don't forget to send an activation email)
         $uri = JURI::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $userdata['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $userdata['activation'], false);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $userdata['name'], $userdata['sitename']);
         $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $userdata['name'], $userdata['sitename'], $userdata['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $userdata['activation'], $userdata['siteurl'], $userdata['username'], $userdata['password']);
         $appSettings = JHotelUtil::getInstance()->getApplicationSettings();
         $fromName = $appSettings->company_name;
         $confirmEmail = $appSettings->company_email;
         $mail = new JMail();
         $response = $mail->sendMail($confirmEmail, $fromName, $userdata['email'], $emailSubject, $emailBody);
         if ($response !== true) {
             JError::raiseWarning('', JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED', true));
         }
     } else {
         // no we need no activation
         $userdata['block'] = 0;
         // don't block the user
     }
     //now to add the new user to the dtabase.
     if (!$user->bind($userdata)) {
         $this->log->LogDebug("Exception when binding user - confirmtion" . JText::_($user->getError()));
         JError::raiseWarning('', JText::_($user->getError()));
         // something went wrong!!
     }
     if (!$user->save()) {
         // now check if the new user is saved
         $this->log->LogDebug("Exception when adding user_id to confirmtion" . JText::_($user->getError()));
         JError::raiseWarning('', JText::_($user->getError()));
         // something went wrong!!
     }
     return $user->id;
 }
Example #27
0
 function sendMailTo($listOfRecipients, $subject, $message)
 {
     $app = JFactory::getApplication();
     $mailFrom = $app->getCfg('mailfrom');
     $fromName = $app->getCfg('fromname');
     JMail::sendMail($mailFrom, $fromName, $listOfRecipients, $subject, $message);
 }
 /**
  * @param JMail $mail
  */
 private function set_to(&$mail)
 {
     $addr = $this->FieldsBuilder->Fields['sender1']['Value'];
     $mail->addRecipient(JMailHelper::cleanAddress($addr));
 }
Example #29
0
 /**
  * Create a mailer object
  *
  * @access private
  * @return object JMail
  * @since 1.5
  */
 private static function &_createMailer()
 {
     jimport('joomla.mail.mail');
     $conf =& JFactory::getConfig();
     $sendmail = $conf->getValue('config.sendmail');
     $smtpauth = $conf->getValue('config.smtpauth');
     $smtpuser = $conf->getValue('config.smtpuser');
     $smtppass = $conf->getValue('config.smtppass');
     $smtphost = $conf->getValue('config.smtphost');
     $smtpsecure = $conf->getValue('config.smtpsecure');
     $smtpport = $conf->getValue('config.smtpport');
     $mailfrom = $conf->getValue('config.mailfrom');
     $fromname = $conf->getValue('config.fromname');
     $mailer = $conf->getValue('config.mailer');
     // Create a JMail object
     $mail =& JMail::getInstance();
     // Set default sender
     $mail->setSender(array($mailfrom, $fromname));
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->useSendmail($sendmail);
             break;
         default:
             $mail->IsMail();
             break;
     }
     return $mail;
 }
Example #30
0
 /**
  * This function is used to override the send function in Joomla
  */
 public static function getMailer($mailing, $html = 0)
 {
     $fromname = empty($mailing->fromname) ? trim($GLOBALS[JNEWS . 'sendmail_name']) : trim($mailing->fromname);
     $fromemail = empty($mailing->fromemail) ? trim($GLOBALS[JNEWS . 'sendmail_email']) : trim($mailing->fromemail);
     $frombounce = empty($mailing->frombounce) ? trim($GLOBALS[JNEWS . 'sendmail_from']) : trim($mailing->frombounce);
     if (empty($fromemail)) {
         $my = JFactory::getUser();
         $userSender = jNews_Subscribers::getUsers('gid', '50', $my->id);
         $fromemail = $userSender[0]->email;
         if (empty($fromemail)) {
             jnews::printM('no', 'The sender email needs to be specified in the configuration.');
             return false;
         }
     }
     if (empty($frombounce)) {
         $frombounce = $fromemail;
     }
     $attachments = $mailing->attachments;
     $images = $mailing->images;
     $conf = JFactory::getConfig();
     $frombounceName = $fromname ? $fromname : $conf->get('config.fromname');
     if (empty($fromemail)) {
         $fromemail = trim($conf->get('config.mailfrom'));
     }
     if (empty($fromname)) {
         $fromname = trim($conf->get('config.fromname'));
     }
     jimport('joomla.mail.mail');
     $phpmailerPath = JPATH_LIBRARIES . DS . 'phpmailer' . DS;
     $mail = new JMail();
     $mail->PluginDir = $phpmailerPath;
     $mail->SetLanguage('en', $phpmailerPath . 'language' . DS);
     $mail->WordWrap = 150;
     //      	$mail->addCustomHeader("X-Mailer: ".JNEWS_JPATH_LIVE);
     //      	$mail->addCustomHeader("X-MessageID: $mailing->id");
     if ($GLOBALS[JNEWS . 'mail_format'] == '1') {
         $mail->Encoding = 'base64';
     }
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $frombounceName = '';
     }
     if (!empty($frombounce)) {
         if (version_compare(JVERSION, '3.0.0', '<')) {
             $mail->addReplyTo(array($frombounce, $frombounceName));
         } else {
             $mail->addReplyTo(array($frombounce));
         }
         JRequest::setVar('bounceBackEmail', $frombounce);
     }
     $mail->From = trim($fromemail);
     if ($GLOBALS[JNEWS . 'minisendmail']) {
         $mail->FromName = '';
     } else {
         $mail->FromName = $fromname;
     }
     $mail->Sender = trim($GLOBALS[JNEWS . 'sendmail_from']);
     if (empty($mail->Sender)) {
         $mail->Sender = '';
     }
     switch ($GLOBALS[JNEWS . 'emailmethod']) {
         case 'mail':
             $mail->IsMail();
             break;
         case 'sendmail':
             $mail->IsSendmail();
             $mail->Sendmail = $GLOBALS[JNEWS . 'sendmail_path'] ? $GLOBALS[JNEWS . 'sendmail_path'] : $conf->get('config.sendmail');
             break;
         case 'smtp':
             $mail->IsSMTP();
             $mail->Host = $GLOBALS[JNEWS . 'smtp_host'] ? $GLOBALS[JNEWS . 'smtp_host'] : $conf->get('config.smtphost');
             $mail->Port = $GLOBALS[JNEWS . 'smtp_port'] ? $GLOBALS[JNEWS . 'smtp_port'] : $conf->get('config.smtpport');
             $mail->SMTPSecure = $GLOBALS[JNEWS . 'smtp_secure'] ? $GLOBALS[JNEWS . 'smtp_secure'] : '';
             if ((bool) $GLOBALS[JNEWS . 'smtp_auth_required']) {
                 $mail->SMTPAuth = $GLOBALS[JNEWS . 'smtp_auth_required'];
                 $mail->Password = $GLOBALS[JNEWS . 'smtp_password'];
                 $mail->Username = $GLOBALS[JNEWS . 'smtp_username'];
             }
             break;
         default:
             $mail->Mailer = $conf->get('config.mailer');
             break;
     }
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (basename($attachment) !== 'index.html') {
                 $mail->AddAttachment(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . DS . basename($attachment));
             }
         }
     }
     switch (substr(strtoupper(PHP_OS), 0, 3)) {
         case "WIN":
             $mail->LE = "\r\n";
             break;
         case "MAC":
         case "DAR":
             $mail->LE = "\r";
         default:
             break;
     }
     return $mail;
 }