help with sending e-mail from form using php.

champion036983

New Member
Messages
4
Reaction score
0
Points
0
I am trying to send an e-mail using a form in dreamweaver and this php code. I get back the correct message saying "thank you for your interest!" but no email is sent. I seen where the mail() function was disabled in x10 so I tried using the smtp option but mail.php is not on the website. I then found out that mail() was reenabled for x10 so I want back to using that. I have recoded this about a thousand times but haven't got an email yet at any of the emails I have tried eathier in normal mail or junk mail. Please help m8's. thank you in advance for replying.


<?php
/* Subject and email variables*/
/*require_once "Mail.php";
$from = "Customer <champion0369@hcautomart.x10.mx>";
$to = "Bryant Harrison <champion0369@hotmail.com>";*/

$subject = 'Vehicle Inquiry from your website';
$webMaster = 'champion0369@yahoo.com';

/* Gathering data variables */
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$primphone = $_POST['primphone'];
$altphone = $_POST['altphone'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$cmake = $_POST['cmake'];
$cmodel = $_POST['model'];
$cyear = $_POST['cyear'];
$cmiles = $_POST['cmiles'];
$ccomments = $_POST['ccomments'];
$ctitle = $_POST['ctitle'];
$pstocknum = $_POST['pstocknum'];
$pprice = $_POST['pprice'];
$pmake = $_POST['pmake'];
$pmodel = $_POST['pmodel'];
$pyear = $_POST['pyear'];
$pmiles = $_POST['pmiles'];
$pacc = $_POST['pacc'];
$pcomments = $_POST['pcomments'];

$body = <<<EOD
<br><hr><br>
E-mail: $email <br>
First Name: $fname <br>
Last Name: $lname <br>
Primary Phone: $primphone <br>
Alt Phone: $altphone <br>
Address: $address <br>
City: $city <br>
State: $state <br>
Zip: $zip <br><br>
Information about their vehicle <br>
Make: $cmake <br>
Model: $cmodel <br>
Year: $cyear <br>
Miles: $cmiles <br>
Comments: $ccomments <br>
Has a clear title: $ctitle <br>
They want information about stock number: $pstocknum <br>
They have a price_range of: $pprice <br>
Or they may also want information about: <br>
Make: $pmake <br>
Model: $pmodel <br>
Year: $pyear <br>
Miles: $pmiles <br>
Accessories: $pacc <br>
Comments: $pcomments <br>
EOD;
$headers = "From: $fname<$email>\r\n";
/*$headers .= "Content-type: text/html\r\n";*/

/*$host = "mail.hcautomart.x10.mx";
$username = "champion0369";
$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);*/


$to = $webMaster;


/* Results */

$success = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>Thank you for your interest!</p>
<p><a href="http://hcautomart.x10.mx/">Home</a></p>
</body>
</html>
EOD;
/*if(PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} Else {
echo "$theResults";
}*/
if(mail($to, $subject, $body, $headers))
{
echo($success);
}
else
{
echo("<p>Message delivery failed...</p>");
}
?>

---------- Post added at 01:28 AM ---------- Previous post was at 12:46 AM ----------

I decided to try a sample code I found on the internet that was supposed to be one of the simplest code to send an e-mail. I tried this code with every e-mail account i have and never got an e-mail in eaither the normal or spam e-mail. This was an idea to relieve some stress, getting an e-mail of anykind though php woulda been a start... Now I'm getting ready to punch out one of my monters. Thanks again guys for your help.

<?php
/*
From http://www.html-form-guide.com
This is the simplest emailer one can have in PHP.
If this does not work, then the PHP email configuration is bad!
*/
$msg="";
if(isset($_POST['submit']))
{
/* ****Important!****
replace name@your-web-site.com below
with an email address that belongs to
the website where the script is uploaded.
For example, if you are uploading this script to
www.my-web-site.com, then an email like
form@my-web-site.com is good.
*/
$from_add = "champion0369@hcautomart.x10.mx";
$to_add = "champion0369@gmail.com"; //<-- put your yahoo/gmail email address here
$subject = "Test Subject";
$message = "Test Message";

$headers = "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";


if(mail($to_add,$subject,$message,$headers))
{
$msg = "Mail sent OK";
}
else
{
$msg = "Error sending email!";
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test form to email</title>
</head>
<body>
<?php echo $msg ?>
<p>
<form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='post'>
<input type='submit' name='submit' value='Submit'>
</form>
</p>

</body>
</html>
 
Top