-1

I want to create an email pop up window when an email address is clicked. Right now I have an email address click-able with a HTML link <a>. I know HTML has a mailto element but I do NOT want to launch the user's email program to email. I would like to email directly from the form. I have seen some PHP examples such as a "contact us" form where a business's (receiver) address is predefined in a PHP file. But I want to be able to email to the email address that is clicked on. So I need to be able to dynamically change receiver email address to the email address that is clicked on.

Any advice for these problems?

I'm not to familiar with PHP or JavaScript but I'm thinking this is possible.

Thanks

Trinimon
  • 13,839
  • 9
  • 44
  • 60
user1899872
  • 127
  • 2
  • 4
  • 15
  • what u have tried so far – M Khalid Junaid Apr 28 '13 at 13:52
  • possible duplicate of [How do I send email with JavaScript without opening the mail client?](http://stackoverflow.com/questions/14268796/how-do-i-send-email-with-javascript-without-opening-the-mail-client) – Pointy Apr 28 '13 at 13:57
  • If you are not familiar with PHP or JavaScript you have a long way to go. PHP can "send email" but the only way JavaScript would be involved is if it was an AJAX request to the web server's PHP script. – SomeShinyObject Apr 28 '13 at 13:59

1 Answers1

2

make the mail adress clickable:

<a target="popup" onclick="window.open('', 'popup', 'width=580,height=360,scrollbars=no, toolbar=no,status=no,resizable=yes,menubar=no,location=no,directories=no,top=10,left=10')" href="sendMail.php?mail=foo@example.com">foo@example.com</a>

Thats it for the site the user comes from.

The "sendMail.php" looks like this:

<?php
if(isset($_GET["mail"] ,$_POST["subject"] ,$_POST["message"] ,$_POST["headers"])) {
    // to:
    $mail = $_GET["mail"];
    // subejct:
    $subject = $_POST["subject"];
    // message:
    $message = $_POST["message"];
    // headers ("From:".$from):
    $headers = $_POST["headers"];
    // sendMail
    mail($mail, $subject, $message, $headers);
} elseif(isset($_GET["mail"])) {
    $mail = $_GET["mail"];
    echo '
<html>
    <head>
        <title>Mail to <?php echo $mail; ?></title>
    </head>
    <body>
        <form action="sendMail.php" method="post">
            // All inputs w/ names
        </form>
    </body>
</html>';
} else {
    echo "Error";
} ?>
Lior Nitzan
  • 68
  • 1
  • 7
Julius Rickert
  • 410
  • 3
  • 13
  • thanks. new to this so I had a question. The $_GET will be looking for the element value with name "mail"...right? Correct me if I am wrong. So wouldn't I need to give an id/name of "mail" to the from the html page. – user1899872 Apr 28 '13 at 15:39
  • Yes you're right. I've edited it in my post. – Julius Rickert Apr 28 '13 at 16:12