Jump to Real's How-to Main page

Send email without CGI

Works with Netscape. The important thing is to NAME all the INPUT. The browser will prompt the user that an email is about to be sent.
<FORM METHOD=POST
      ACTION="mailto:someone@somewhere.com"
      ENCTYPE="text/plain">
<INPUT TYPE="hidden" VALUE="1234" name="score">
<INPUT TYPE="hidden" VALUE="Mr. Smith" name="player">
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
To set the subject :
ACTION="MAILTO:SOMEONE@SOMEWHERE.COM?SUBJECT=AUTOMATIC_EMAIL"
To send a Carbon Copy of the message to a second person, use the "cc" parameter :
<FORM METHOD=POST
      ACTION="mailto:someone@somewhere.com?subject=important&cc=someoneelse@somewhere.com"
      ENCTYPE="text/plain">
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
While you can use a FORM to define the message body, it's also possible to define the body directly in the mailto: URL :
mailto:someone@somewhere.com?body=HelloWorld
Thanks to Aneesha Bakharia for the following tip :

I've seen Javascript being used to neatly format form data so that it can be received in a readable manner. This tip achieves a similar outcome but requires no Javascript at all. Simply add ENCTYPE="text/plain" into the opening form tag. Remember to name all your form elements. Here is the HTML for a sample form you could use to hire me as a web developer:

      <form METHOD="POST" ENCTYPE="text/plain"
      action="mailto:bakharia@squirrel.com.au">
      <input type="hidden" name="Type of Form" value="Employment">
      <table border="0" width="80%">
      <tr>
      <td width="197" valign="top">
      <b>Enter Your Name:</b></td>
      <td width="462">
      <input type="text" name="Name" SIZE="50" MAXLENGTH="50">
      </td>
      </tr>
      <tr>
      <td width="197" valign="top">
      <b>Enter your Email address:</b>
      </td>
      <td width="462">
      <input type="text" name="Email" SIZE="50" MAXLENGTH="50">
      </td>
      </tr>
      <tr>
      <td width="197"  valign="top">
      <b>Your Request:</b>
      </td>
      <td width="462">
      <textarea name="Comment" wrap="physical" rows="7" cols="48">
      </textarea>
      </td>
      </tr>
      <tr>
      <td width="535" colspan="2">
      <b><div align="center"><center><p></b>
      <input type="submit" VALUE="Send Form">
      <input type="reset" Value="Reset Form">
      </td>
      </tr>
      </table>
      </form>
Here is what your email will look like:
      Type of Form=Employment
      Name=Your Name goes here
      Email=Your email address here too
      Comment=Make a comment

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]