?
Solved

Share webpage by email and grab sended emails

Posted on 2013-01-25
7
Medium Priority
?
387 Views
Last Modified: 2013-11-26
Hello Experts.

I have a "share by email" link in my page which is currently using a normal email client, do you know any service without the need of email client such as outlook, to present on the page just like sharethis works with emails, but when a user sends and email we could grab both emails (the person who sends the email and the one that receives)?

Working with php and jquery in my website.

Thank you
0
Comment
Question by:joao_c
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 38819290
0
 

Author Comment

by:joao_c
ID: 38819321
Sorry, not email client. In the website I have a "share by email" link, and I want to grab the email adresses from both the sender and receiver.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38825290
Can you please post a link to the page that contains the "share by email" link?  Thanks, ~Ray
0
 

Author Comment

by:joao_c
ID: 38825520
Here is the html:

<li class="email"><a href="mailto:?subject=text_here&amp;body=Body text">E-mail</a></li>

Open in new window


Instead of launching a client email program like outlook, windows live mail.. I just want a pop-up window, with an email from, email to send and message,. When the users use that I want to grab the info sended.

Thank you Ray
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 38826343
The general design would work something like this...

1. JavaScript (perhaps jQuery) would be used to create the pop-up window.  Something like window.open() could be used to start a PHP script in that window.
2. The PHP script would present a form to request the email addresses (both from and to) and a message.
3. When the form is submitted the action script would record the email addresses, along with the text of the message and the URL of the web page, in your data base logging table.
4. Then the action script would use the PHP mail() function to send the email message.

Some things to be VERY careful about... Sanitize your data with great care.  Form-to-email scripts are considered a target-rich environment by the script-kiddie hacker community, and as soon as they identify your pop-up script you can bet it will be bombarded by attacks.  Suggest your script sleep() at least two seconds between executions, and perhaps most importantly, implement a CAPTCHA test in the popup window.  Details about how to make CAPTCHA suck less are available in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_9849-Making-CAPTCHA-Friendlier-with-PHP-Image-Manipulation.html

Sanitization would mean ensuring that the from and to email addresses pass the test of being actual, individual, well-formed email addresses, that they are routable via the DNS.  This code snippet can help with that.

<?php // RAY_email_validation.php
error_reporting(E_ALL);


// A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE
// SEE MAN PAGE: http://php.net/manual/en/intro.filter.php
function check_valid_email($email, $rout=TRUE)
{
    // LIST OF BLOCKED DOMAINS
    $bogus = array
    ( '@unknown.com'
    , '@example.com'
    , '@gooseball.org'
    )
    ;

    // IF PHP 5.2 OR ABOVE, WE CAN USE THE FILTER
    if (strnatcmp(phpversion(),'5.2') >= 0)
    {
        if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) return FALSE;
    }

    // IF LOWER-LEVEL PHP, WE CAN CONSTRUCT A REGULAR EXPRESSION
    else
    {
        $regex
        = '/'                        // START REGEX DELIMITER
        . '^'                        // START STRING
        . '[A-Z0-9_-]'               // AN EMAIL - SOME CHARACTER(S)
        . '[A-Z0-9._-]*'             // AN EMAIL - SOME CHARACTER(S) PERMITS DOT
        . '@'                        // A SINGLE AT-SIGN
        . '([A-Z0-9][A-Z0-9-]*\.)+'  // A DOMAIN NAME PERMITS DOT, ENDS DOT
        . '[A-Z\.]'                  // A TOP-LEVEL DOMAIN PERMITS DOT
        . '{2,6}'                    // TLD LENGTH >= 2 AND =< 6
        . '$'                        // ENDOF STRING
        . '/'                        // ENDOF REGEX DELIMITER
        . 'i'                        // CASE INSENSITIVE
        ;
        // TEST THE STRING FORMAT
        if (!preg_match($regex, $email)) return FALSE;
    }

    // TEST TO SEE IF THE DOMAIN IS IN OUR BLOCKED LIST
    foreach ($bogus as $badguy)
    {
        if (stripos($email, $badguy)) return FALSE;
    }

    // FILTER_VAR OR PREG_MATCH DOES NOT TEST IF THE DOMAIN IS ROUTABLE
    if ($rout)
    {
        $domain = explode('@', $email);

        // MAN PAGE: http://php.net/manual/en/function.checkdnsrr.php
        if ( checkdnsrr($domain[1], "MX") || checkdnsrr($domain[1], "A") ) return TRUE;

        // EMAIL IS NOT ROUTABLE
        return FALSE;
    }
    return TRUE;
}



// DEMONSTRATE THE FUNCTION IN ACTION
$e = NULL;
if (!empty($_GET["e"]))
{
    $e = $_GET["e"];
    if (check_valid_email($e))
    {
        echo "<br/>VALID: $e \n";
    }
    else
    {
        echo "<br/>BOGUS: $e \n";
    }
}


// END OF PROCESSING - CREATE THE FORM USING HEREDOC NOTATION
$form = <<<ENDFORM
<form>
TEST A STRING FOR A VALID EMAIL ADDRESS:
<input name="e" value="$e" />
<input type="submit" />
</form>
ENDFORM;

echo $form;

Open in new window

And finally, do not send the message "from" the from email address that was entered on the form.  You'll quickly fail an SPF test  and your server will be marked as a spammer.  Instead, send it from noReply at your domain.  Include the from email in the message.

Best of luck with your project, ~Ray
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question