Email admin on script install Automatically

Posted By: Ian on Feb 01, 2015 in PHP, Snippets

Question
OK i have a script i wrote which people can use on there sites as longs they link back to my site, but they nearly never do! I don’t want them to be forced to fill out anything as then they might not bother with my script but how can i increase the odds of people linking back?

Answer
Below is a function which will attempt to email the website owner using the email address set by the server or site owner if running on virtual host. To use it edit the Constants and simply call the function at a frequency of your choice. Of course when the link back is placed your want a way of stopping the emails or a checker script using something like google advanced search yoursite.com site:theresite.com where if result found don’t send email else send. But you can have a go at that.

<?php
define('scriptName', 'Maxi');
define('scriptOwner', 'Ian.J.Gough');
define('emailFrom', 'alert@yourdomain.com');
define('scriptLicence', 'http://ianjgough.com/licence.html');

function emailAdmin()
{
    $to      = serverAdmin;
    $subject = "Thank you for installing my script but did you link back?";
    $message = "Hello, and Thank you for installing my script " . scriptName . " but did you remember to link
 back?<br />Please check the <a href=\"" . scriptLicence . "\">licence</a> 
conditions before continuing use or uninstall it and your not be bothered again.<br />Thankyou for your time,
 " . scriptOwner;
    $header  = "From:" . emailFrom . " \r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-type: text/html\r\n";
    $result = mail($_SERVER['SERVER_ADMIN'], $subject, $message, $header, '-f' . emailFrom);
    if ($result == true) {
        echo "Message sent successfully...";
    } else {
        echo "Message could not be sent...";
    }
}
print emailAdmin();
?>

Download

AnonymousIan.J.Gough

Did this help you? Please Let me know by commenting below even if it’s just to say “Thanks”

leave a comment

About This Site

Dreams are built from lines of code well it's true!
If you can dream it you can usually code it.

I have learned so much from other people on the Internet and this site is for me to give back some of what i have learned and hope people can now learn from me.
Have fun and surf safely,
Ian.J.Gough

protected by copyscape duplicate content check

Categories


Powered by Banner Bar 125