Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Thanked 0 Times in 0 Posts

    Search Box with Email Function

    I would like to create a search box on my webpage with one added feature. If a user enters a value or string that cannot be found on the webpage, I would like the site to automatically send me an email with the said string or value that was entered. Before doing so, I would like a text box to popup and ask for the users email so that that information can be emailed to me as well allowing for me to respond to the user.

    I'm not sure exactly how to go about adding these extra features. If someone could help me out that would be fantastic!

    Thank you so much.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,323 Times in 4,289 Posts
    The only guaranteed way to do this is to use server-side code (PHP, JSP, ASP, et al.) to send the email.

    *SOME* browsers will be correctly connected to a user's email client so you can do it from the browser, but likely that is around 1/3 to 1/2 of all users. On top of that, the email clients often issue what look like dire warnings to the users, telling that their email address will be revealed, etc., etc., if they proceed.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,530 Times in 2,508 Posts
    The trouble with using this long-obsolete method (mailto) to send form results is its unpredictability. The method it is highly dependent on the browser in use and the email client in use (some people have only Yahoo, Gmail or Hotmail). In particular, your visitor must have Outlook or Outlook Express or Windows Live Mail as the default client for this to work correctly. Even if your visitor is using Internet Explorer, but the default mail client is different (e.g. Eudora or Thunderbird), your mailto form will not work. With all of the browser troubles, you're likely to lose about half of your users' messages. Most of the email clients that can successfully send a mail will prompt the user with a somewhat threatening security dialog prior to sending - this can scare many users from continuing. Other users will not wish to reveal their email address. Also, what about people with Javascript disabled?

    In addition, if you place an unobfuscated email address in your webpage, the bots will quickly find it and inundate you in spam.

    Modern browsers no longer accept mailto: as a form action - they simply open the email program (if any) and ignore the form.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts