Created
March 10, 2018 11:13
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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