View Full Version : Need Help creating a PHP mail form

07-20-2010, 07:30 PM
Can someone point me to a tutorial in creating a php web form that will allow me to send an email with the following features.

1. Send email to multiple addresses
2. Send the user a confirmation email with the info entered

Example form:
(Text boxes)
Last name:____________
Address 1:____________
Address 2:____________
Day Time Phone:_______________

(Check Box)
_Agree to Terms

(Radio Button)
* Option 1
* Option 2

If option 1: Send emails to a@example.com , b@example.com, c@example.com

If option 2: Send emails to d@example.com , e@example.com, f@example.com

07-20-2010, 08:59 PM
This is a tutorial that I used for a newsletter that sends to multiple emails. The idea of what you want is similar so you'll have to modify what is show sot your needs but the concept seems the same to me.

It is a 3 part tutorial I believe.

07-21-2010, 02:45 AM
use mail function as normal.

07-21-2010, 04:35 AM
Something like

<form method="post" action="<?php echo $_SERVER['php_self']; ?>">
<input type="text" name="email" />
<input type="submit" name="Submit" />

if (isset($_POST['Submit']) {
$email = $_POST['email'];
$subject = "Subject";
$body = "Body of email";
if (mail($email, $subject, $body)) {
} else {
echo "Email failed";

Post code for a more detailed answer or see http://php.net/manual/en/function.mail.php

Jangokoo, you should provide a coding sample or a link rather than just giving a user the name of a function.

07-21-2010, 02:48 PM
1. Send email to multiple addresses
2. Send the user a confirmation email with the info entered

sending to multiple users: just put the email addresses in a comma-separated list.

sending confirmation email: Look at bluewalrus' example. Where he has the //emailed comment, you can put code to send a second email - same way you sent the first - to the user, that has your confirmation note.

07-22-2010, 05:07 PM
@bluewalrus : ok, I will take note this :D.
In addition, I was successful to send email by localhost(I mean by mercury mail server).
But when I try a free host(byehost), I dont know how to configure the mail server to send mail? Any ideas for this?(I tried to search it but no result) Can anyone using byehost help me.
Thanks alot

07-22-2010, 07:28 PM
I don't know about byehost in particular, but free hosts usually don't support sending emails. ask them to be sure.