Skip to content

Instantly share code, notes, and snippets.

@robwent
Created March 10, 2018 11:13
Show Gist options
  • Select an option

  • Save robwent/69e39abfe2e4a7d7fc0df05671b1554b to your computer and use it in GitHub Desktop.

Select an option

Save robwent/69e39abfe2e4a7d7fc0df05671b1554b to your computer and use it in GitHub Desktop.
Email notification for broken links for Joomla. Add to your templates error.php file.
<?php
// Check for a referer and if so send mail
if (isset($_SERVER["HTTP_REFERER"])){
$sitename = "My Website";
// Mail Settings
$mailer = JFactory::getMailer();
// Set sender as site default
$config = JFactory::getConfig();
$sender = array(
$config->get('config.mailfrom'),
$config->get('config.fromname') );
$mailer->setSender($sender);
// Set recipient
$recipient = '[email protected]';
$mailer->addRecipient($recipient);
// Mail body
$body = "404 page alert for " . $sitename . "\n\n The user was referred from " . $_SERVER["HTTP_REFERER"] . " \n\n They were trying to reach a page at " . JURI::base() . ltrim($_SERVER['REQUEST_URI'], '/');
$subject = "404 Error Alert for " . $sitename;
$mailer->setSubject($subject);
$mailer->setBody($body);
$send = $mailer->Send();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment