views:

107

answers:

7

Is a server side script necessary to send a form to email?

For example, suppose I want to submit this form. Is it only possible with php asp.net etc. or it can be done with javascript only?

<HTML>
   <HEAD>
     <TITLE>HTML form tutorial example</TITLE>
   </HEAD>
   <BODY>

    <H1>HTML form tutorial example</H1>

    <FORM>

    Name: <INPUT TYPE="TEXT" NAME="Name" VALUE="" SIZE="25" MAXLENGTH="50"> <BR>

    Email: <INPUT TYPE="TEXT" NAME="Email" VALUE="" SIZE="25" MAXLENGTH="50"><BR>

    <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Sign Me Up!">

    </FORM>

   </BODY>
</HTML>
+4  A: 

You need a server-side language to process it.

Dean Harding
@codeka - process means?
metal-gear-solid
"process" means to handle the data (form input) that gets sent back to the server. i.e., to email it.
Mark
A: 
Gaby
pls tell me how to send this in PHP
metal-gear-solid
mail() function
zerkms
@jitendra, i added some links in my answer..
Gaby
A: 

You might be able to tweak your server to selectively log particular URLs. In this way, you could log submissions of your form to a designated lot for later processing. If needed, you could download the log remotely via FTP or SCP and then process the log on another machine. Apache will allow you to perform selective logging. Not sure if this solution will be too useful though. If you cannot put on a dynamic language, you probably cannot change your logging configuration. Good Luck.

Jacob

TheJacobTaylor
+2  A: 

No, not necessarily. I mean, you do need to have a server process the information, but you yourself don't personally have to write that server program. If you're using one the online services for e-mail list processing (MailChimp, etc.) then you can use their code which you can get off their site. It will submit to their servers. Another way is you can construct a URL which will report to another account and get the data off that way for manual processing.

Plynx
A: 

You can use Ajax.

sundowatch
and... doesnt ajax require a server-side language?
DaNieL
+1  A: 

There is the possibility of using a mailto: URL for the form's action, like this:

<form action="mailto:[email protected]" entype="text/plain" method="post">
    <input type="hidden" name="subject" value="The subject line of the email" />
    <input type="text" name="themessage" value="Hey there" />
    <input type="submit" value="Send the message" />
</form>

This will fire up the user's mail client and paste the form data into the message body. They will, however, have to hit "send" in the mail client - this won't actually automatically send anything without that extra step.

This will not work if the client doesn't have a handler set up for mailto: links (ie: They don't have a mail program installed).

Marc B
Worth noting that for many people with web-based mail accounts, this will not work and will actually confuse them by sending them to something like Outlook Express--mailto links are so unreliable these days :(
Plynx
A: 

Generally: Yes, you need a server-side language to process the form data.


But the question reminded me of something I read looong ago; in the really early days using mailto in the target was quite common (at least for amateur "home pages"), like this:

<form action="mailto:[email protected]" method="post" enctype="text/plain" >

Did a quick search and found this.

It's dirty as heck, and I guess it relies on the user having a default mail-client set up (which may not really be the case anymore, with webmail clients becoming more common), and some browsers may not support it (though it would suprise me if they didn't). You also expose your email address for easy scraping by spammers. You have no control of the formatting, etc...

Note I'm not saying you should do this, just that it may be possible to do.


It's allso possible to use javascript to format some data pulled from the form and place it in the href of a link using some additional keywords to control the text and subject (just google "mailto link"). I've actually used that as a simple low-tech solution to report errors (which works even if the error is caused by the server being offline).

Stein G. Strindhaug