Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:54:39+00:00 2026-06-04T22:54:39+00:00

I have a script that fires off a email everytime someone comments on by

  • 0

I have a script that fires off a email everytime someone comments on by FaceBook comment box. Fb.event.subscribe triggers a ajax call to mail.php on my server, which fires off a email to my email address to notify of a new comment. How do i make this more secure and block access to mail.php directly?

        FB.Event.subscribe('comment.create', function (response) {
            var domain = "<?= $_SERVER['SERVER_NAME']; ?>";
            var url = "<?= $currentUrl ?>";
                alert("comment added");

                            var xmlhttp;
                            if (window.XMLHttpRequest)
                              {// code for IE7+, Firefox, Chrome, Opera, Safari
                              xmlhttp=new XMLHttpRequest();
                              }
                            else
                              {// code for IE6, IE5
                              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                              }

                            xmlhttp.open("GET","http://" + domain + "/mail.php?url=" + url,true);
                            xmlhttp.send();

        });


** ---------- here is mail.php -------- **



<?php 
    $to = "MY EMAIL HERE";
    $subject = "New Comment Added";
    $message = "New Comment posted here: " . $_GET['url'] ;
    $from = "MY EMAIL HERE";
    $headers = "From:" . $from;
    //mail($to,$subject,$message,$headers);
    //echo  $_GET['accesstoken'] ;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:54:40+00:00Added an answer on June 4, 2026 at 10:54 pm

    You cannot do this. If you enable the client to access mail.php with client-side code, then anyone can access it with a script as well. You can try to obfuscate it as much as you want, but if someone really wants to find out how to access it they will.

    EDIT: The basic rule is, if it can be done in a browser by a human, then it can be done in a script by a computer. The only semi counter-point to this rule are CAPTCHAs, but even these can be circumvented nowadays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app that spawns off a script that runs a Nutch
I have a script running on windows box that downloads files from the net
I have a batch script that triggers vlc for me on my network, the
Have a shell script that reads the files in a particular directory. #!/bin/bash for
I have created a script that saves some files in the Documents directory of
I have created a script that will upload files to a general uploads folder,
I have a PHP script that creates other PHP files based on user input.
I have an ant build script that needs to pull files down from a
I have a script in python that needs to read iso-8859-1 files and also
I want to copy files that have timestamps from the time the script begins

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.