I have a form where someone can send me a message but I do not seem to get the e-mail.

here is the html file:

<!DOCTYPE HTML>
<html>
<head>
<title>Financial E-mail: Send us questions.</title>

<hr/>
<style type="text/css">
body
{
background-color: rgb(98,21,153);;
background-position: top;
background-repeat: no-repeat; 
color: gold;

}
a:link {color:rgb(255,215,0);}/* unvisited link */
a:visited {color:rgb(205,215,03);}/* visited link */
a:hover {color:rgb(0,0,0);}  /* mouse over link */
a:active {color:rgb(255,255,255);} /* selected link */
.center
{
margin:auto;
width:70%;
}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}
p.color {color:azure};


</style>
</head>

<body>
<p> Here you can send questions to the website moderator viva e-mail. Any flaws or bugs should be sent to this address:financialmod@yahoo.com</p>
<br/>
<br/>

<form method="post" action="FinancialEmail.php" >
<p>Email Address: <input type="text" name ="email" size="40" /> </p>
<p>Subject: <input type="text" name ="subject" size="20" /> </p>
<p>MessageS:<textarea name='message' rows='15' cols='40'>
  </textarea>
</p>

<input type="submit" name ="submit" value="Submit!"/>
</body>
</html>

here is the php file:

<!DOCTYPE HTML>
<html>
<head>
<title>Financial E-mail: Send us questions.</title>

<hr/>
<style type="text/css">
body
{
background-color: rgb(98,21,153);;
background-position: top;
background-repeat: no-repeat; 
color: gold;
}
a:link {color:rgb(255,215,0);}/* unvisited link */
a:visited {color:rgb(205,215,03);}/* visited link */
a:hover {color:rgb(0,0,0);}  /* mouse over link */
a:active {color:rgb(255,255,255);} /* selected link */
.center
{
margin:auto;
width:70%;
}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}
p.color {color:azure};


</style>
</head>

<body>

<br/>
<br/>
<?php

$email1 = $_POST['email'];
$subject1 = $_POST['subject'];
$message1 = $_POST['message'];

 /*

if ( mail($email, $subject, $message) )
{
     echo("Your email message was successfully sent.");
}
else
{
     echo("Sorry, message delivery failed. Contact webmaster for more info.");
}
*/

/*

<form method="post" action="contact.php"> 
 Email: <input name="email" type="text"><br>
 Message:<br> 
 <textarea name="message" rows="15" cols="40"></textarea><br> 
 <input type="submit"> 
 </form> 
  //<?php 
  */  

 //if(isset(
 $message = $message1;
 $to = "financialmod@yahoo.com"; 
 $subject = $subject1; 
 $email = $email1; 
 $from = '$email1';
 $headers = "From: " .$email;
 mail($to, $subject, $message, $headers);
 echo "Mail Sent."; 


 /*$message = $_REQUEST['message'] ; 
 $sent = mail($to, $subject, $message, $headers) ; 
 if($sent) 
 {print "Your mail was sent successfully"; }
 else 
 {print "We encountered an error sending your mail"; }
 ?> 
?>

*/

?>
</html>
</body>

You havent filled in your email to all the correct spots.

Are you checking in local system? You won't receive email without SMTP.
Once you upload this to LIVE you will get emails.

@BSKills: what do you mean?

@Vibhaj :I didn't recieve an e-mail after I sent it.

@trascendent: Are you checking this system in your localhost?
Mail sending code never works in your localhost. Got it or not?

add your email address in every green spot it is showing 'email'

Problem is here.

$email1 = $_POST['email'];
$subject1 = $_POST['subject'];
$message1 = $_POST['message'];
 /*
if ( mail($email, $subject, $message) )

You are storing values in variables, email1, subject1 and message1 but in mail function you are giving email, subject and variable
This is the problem.
here is corrected code

$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
 /*
if ( mail($email, $subject, $message) )

Replace this piece and then let me know

Member Avatar

diafol

BTW - some hosts require that you have specific flags set in your email headers. Check the hosts' FAQ on this.