Click to See Complete Forum and Search --> : send text to an email
Academy
Apr 7th, 2008, 01:50 PM
on the click of a submit button, I'd like to send the text from a textbox to an email address.
textbox: txtTest
from : from@hotmail.com
to: to@hotmail.com
Please provide sample code,
Thanks.
visualAd
Apr 7th, 2008, 02:13 PM
http://www.php.net/mail
dclamp
Apr 7th, 2008, 06:12 PM
you are going to need to send headers for the from part.
Academy
Apr 7th, 2008, 07:37 PM
yes!
dclamp
Apr 7th, 2008, 07:49 PM
did you get it to work?
Academy
Apr 7th, 2008, 07:53 PM
no. it is not working.
<?php
$firstname=(string)$_POST["txtFirst"];
$headers ='haau@shaw.ca'. phpversion();
mail('haaail@shaw.ca','Registration testing',$firstname,$headers);
echo 'done';
?>
dclamp
Apr 7th, 2008, 08:01 PM
try this...
<?php
error_reporting(E_ALL);
$firstname=$_POST["txtFirst"];
$headers ='haau@shaw.ca'. phpversion();
@mail('haaail@shaw.ca','Registration testing',$firstname,$headers);
echo 'done';
?>
Academy
Apr 7th, 2008, 08:18 PM
still not working. I wonder if it has anything to do with the HTML page.
<form id="register" name="register" method="post" action="email.php">
<table width="599" height="368" border="1">
<tr>
<td width="500"><table width="576" height="327">
<tr>
<td width="216"><div align="right" class="normal">First Name: </div></td>
<td width="330"><input name="txtFirst" type="text" id="txtFirst" /></td>
<td width="14"> </td>
</tr>
<tr>
<td><div align="right">
<p class="normal">Last (Family) Name:</p>
</div></td>
<td><input name="txtLast" type="text" id="txtLast" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right">
<p class="normal">Address:</p>
</div></td>
<td><input name="txtAddr" type="text" id="txtAddr" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right">
<p class="normal">Telephone Number:</p>
</div></td>
<td><input name="txtTel" type="text" id="txtTel" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right">
<p class="normal">Cell Number:</p>
</div></td>
<td><input name="txtCell" type="text" id="txtCell" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right">
<p class="normal">AA&ITN:</p>
</div></td>
<td><input name="txtAA" type="text" id="txtAA" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right" class="normal">Trade: </div></td>
<td><input name="txtTrade" type="text" id="txtTrade" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right" class="normal">Best time to contact you: </div></td>
<td><input name="txtBest" type="text" id="txtBest" /></td>
<td> </td>
</tr>
<tr>
<td><div align="right" class="normal">Other Notes: </div></td>
<td><textarea name="textarea"></textarea></td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<p>
<input name="btnSubmit" type="submit" id="btnSubmit" value="Submit" />
</p>
</form>
dclamp
Apr 7th, 2008, 08:41 PM
can you please edit your post using tags or tags, thanks
visualAd
Apr 8th, 2008, 04:05 AM
no. it is not working.
<?php
$firstname=(string)$_POST["txtFirst"];
$headers ='haau@shaw.ca'. phpversion();
mail('haaail@shaw.ca','Registration testing',$firstname,$headers);
echo 'done';
?>
Your headers are incorrectly formatted. They need to be in the format Name: value\r\n.
E.g
$headers = 'From: me@example.com\r\n';
$headers .= 'X-Client:' phpversion();
Also you may want to set the sendmail_from directive n the php.ini to the from address too, to prevent an errornous reply_to header.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.