If you are not happy with the solution FB already provides (as scjosh explained), you can use Facebooks Javascript SDK a bit of ajax (jquery would be my favorite) to load a script with the mail() function.
First load the JS SDK (make sure you change 'YOUR_APP_ID' and the channelURL!!):
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelURL : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
more information about js sdk, the loading and the channel file can be found here. You should have an app or create an app in facebook for that reason. Information about setting up an app is here.
Next step is to load the script with the mail() per jquery:
FB.Event.subscribe('edge.create',
function(response) {
$(document).load('mail.php?response='+response);
}
);
And finally the mail.php:
if(isset($_GET['response'])) {
$msg = 'A comment was left on '.$_GET['response'];
mail('user@webpage.com','New comment',$msg);
}
Hope that helps!