I am trying to have a mailto form that will send text entered to an email address entered above. The email form is the variable "to". how could I have it so when the form is up, someone enters their email the variable to is assigned that email. Here is my code. Thanks in advance -Ben
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--chtml include "//webinfo/incs/header.inc"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Mailto Variable</title>
<link href="/webinfo/webinfo.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h1>Mailto Basic Demo</h1>
<form action="basic.mailto" method="post">
<tr>
<td>Your E-mail Address:</td>
<td><input type="text" name="to" value="" size="55" /></td>
</tr>
<table border="0" cellspacing="2" cellpadding="0">
<tr>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="sendername" value="" size="55" /></td>
</tr>
<tr>
<td valign="top">Comments:</td>
<td><textarea name="comments" rows="15" cols="55">
</textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send Comment" />
<input type="reset" value="Clear Comment" /></td>
</tr>
</table>
</form>
<!--chtml include "//webinfo/incs/footer.inc"-->
</body>
</html>
Here is basic.mailto
<to>"to"</to>
If you intend to use mailto: to send an email, then your form-tag would have to look something like this:
<form method="post" action="mailto:[email protected]">
However, using that method is not a very good one. That method relies on the user having a default e-mail client set up, that can be used to send the email through.
Instead, I would suggest that you use a server-side language to post the email. Have a look at PHPs mail() for instance.
If you intent to send e-mails, it is also worth looking in to web services like Postmark to make sure that your emails are delivered properly and not getting caught in SPAM-filters. There are a libraries for most server-side languages that you can use if you like to use Postmark: http://developer.postmarkapp.com/developer-libs.html