Question

I recently stumbled upon some really cool js which renders a screenshot with a highlighted area for feedback on your website. The website for this program can be found here: http://experiments.hertzen.com/jsfeedback/

However, I'd really like to get it to send an email (to an address of my choosing) once the data is collected instead of whatever it is doing now. I've been looking through it and I'm assuming it would be done in the feedback.js file under

send: function( adapter ) {

However, I'm not entirely sure how to change what is there to keep the screenshot and data.

Was it helpful?

Solution

When you initialize Feedback(), you can set some options. In your case the url option is important. This url should point to a php script which uses the $_POST[] data send by feedback.js. After you got all the data you can send it in an email with php.

Here is an example how to set some options:

Feedback({
    label: 'What is your problem',
    header: 'Report an issue',
    nextLabel: 'Next',
    reviewLabel: 'Review screenshot',
    sendLabel: 'Send email',
    closeLabel: 'Cancel',
    messageSuccess: 'Done!',
    messageError: 'Oops..',
    url: 'path/to/email/sendFeedback.php' // This is what you need
});

In the sendFeedback.php file you should do something like te following

if($_POST) {
    $image = $_POST['data'];
    $otherField = $_POST['your-other-field'];
    // Send email here
}

$_POST['data'] will hold the image as a DOMString. Other input field values are in other parameters depending on which other fields you define.

In php there are many ways to send emails.
mail() is just one of them. Info can be found at php.net..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top