PDA

View Full Version : Send an E-mail with PHP (probably simple)


Dalziel
05-12-2003, 01:20 PM
Sorry if I seem dumb I know next to nothing about PHP.
I've written a form as below.

<form name="feedback" action="sendmail.php">
What is your name? <input type="text" size="25" name="you" /><br />
Where are you from? <input type="text" size="25" name="where" /><br />
What is your E-mail address? <input type="text" size="25" name="email" /><br />
How did you find the site? <input type="text" size="25" name="found" /><br />
Do you have any other comments? <textarea name="comments" cols="15" rows="15"></textarea>
</form>

I want to use PHP to send this to my email address (I believe there's a function called mail()?)

How would I get PHP to send an E-mail looking like this (i.e. what would the code of sendmail.php be?):

----------------------------------------------------------------------------------------

From: E-Mail

Message:
Feedback from [Name], [Where]
[Name] found this site from [Found]

[Comments]

sametch
05-12-2003, 02:05 PM
Daniel

You need to use the following

$mail_to = "you@youremail.com";
$mail_subject = "whatever subject you want to call it";
$mail_body = "message body";

You will need to write a script to collect all your form field entries that have been "posted" and convert them into a "message body"
If you want an idea of how I do it see (if my coding makes any sense):

http://www.codingforums.com/showthread.php?s=&threadid=19850

I am not sure if its the best way to do it but it works (apart from the other problem I am having with that page). Note this form collects field values and processes in one.

hth

Sametch

Fatman
05-13-2003, 11:33 AM
the mail or sendmail function are what u want :)