× This forum has been locked. Please submit new Feature Requests on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues

adding send email function to backend

4 years 8 months ago #1433 by Marcin
It would be nice to have send email function added to edit, create new - buttons on backed.

Please Log in or Create an account to join the conversation.

4 years 5 months ago #1466 by Ruud van Lent
Replied by Ruud van Lent on topic adding send email function to backend

just added this to the front-end form. When a new item is created and saved (via the controllers save function), the following function is called that will send an email to all users that have in their profile 'Receive system emails' set to yes.

hope this helps.
	 * Send mail to administrators
	 * @param   integer  $id  The id of the row to check out.
	 * @return void
	public function sendSystemMail($id)
		// Get the id.
		$id = (!empty($id)) ? $id : (int) $this->getState('newsitem.id');

		$app = JFactory::getApplication('com_ochgotnews');
		$params = $app->getParams();

		if ($params->get('ochgotnews_mailonnew', true))
			$user = JFactory::getUser();

			// Build the email subject and message
			$sitename = JFactory::getApplication()->get('sitename');
			$siteURL = JUri::root() . 'administrator/index.php?option=com_ochgotnews&task=newsitem.edit&id=' . $id;
			$subject = JText::sprintf('COM_OCHGOTNEWS_MAIL_SUBJECT', $sitename);
			$msg = JText::sprintf('COM_OCHGOTNEWS_MAIL_MESSAGE', $siteURL);

			// Get the user that are configured to receive system emails
			$db = JFactory::getDBO();
			$query = $db->getQuery(true);
				->select(array('name', 'email'))
				->where($db->quotename('sendEmail') . ' = ' . $db->quote('1'));
			$recipients = $db->loadObjectList();

			foreach ($recipients as $recipient)
				// Compile mailer function:
				$mailer = JFactory::getMailer()


Please Log in or Create an account to join the conversation.

Time to create page: 0.239 seconds
Powered by Kunena Forum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.