Page 1 of 1

Form submission

Posted: Wed Apr 20, 2011 3:53 am
by greatme
I need somebody to come to my rescue. I have a contact page of my website that handles form from the users but when users submit submit the form from the contact page i don't get to recieve it in the designated webmail account. here is the form_handler code.

<?php
error_reporting(E_ALL - (E_NOTICE + E_WARNING));
$first_name= $_POST["firstname"];
$last_name= $_POST["lastname"];
$email= $_POST["mail"];
$address= $_POST["address"];
$phone= $_POST["mobile"];
$textdata= nl2br($_POST["user_comment"]);
$to = "info@seapmicrofinance.org";
$from = "".$_POST["mail"]."";
$subject = "Online Form";

$message = "Online Form
Hello,
First Name: $first_name
Last Name: $last_name
Email: $email
Address: $address
Phone: $phone
Comment: $textdata ";

$headers = "<info@successpalace.com>\r\n";
$headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);

?>

Re: Form submission

Posted: Wed Apr 20, 2011 4:44 am
by zyntrax
Well it seams you arn't sending it, do you have a smtp server to use?

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "smtp server";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}

Re: Form submission

Posted: Wed Apr 20, 2011 10:07 am
by social_experiment
Any error messages when you send the message?

Re: Form submission

Posted: Wed Apr 20, 2011 10:11 am
by fugix
also i would make $from = $email