Hi Im creating a form in which i enter the user details and provide them user name and password through email for login purpose.
Problem: Using post method i would like to send email to the user. But it shows the email sent but email not yet received.
If to address is directly given email is sent. $to:[email protected] - mail is sent.
Im sending email in localhost using Send mail.
My form is
<form name="assignteacher" method="post" action="../path.php">
<table align="center" width="450px">
<tr>
<td valign="top">
<label for="teacherid">Teacher ID</label>
</td>
<td valign="top">
<input type="text" name="teacherid" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email</label>
</td>
<td valign="top">
<input type="email" name="email" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="username">User Name</label>
</td>
<td valign="top">
<input type="text" name="username" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top"">
<label for="password">Password</label>
</td>
<td valign="top">
<input type="text" name="password" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="class">Class Assigned</label>
</td>
<td valign="top">
<input type="text" name="class" maxlength="80" size="30">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
<a href="http://www.freecontactform.com/email_form.php">Email Form</a>
</td>
</tr>
</table>
</form>
My PHP Code is..
<?php
$emailid=$_POST['email'];
$to='$emailid';
$subject='Your Login info';
$message ="username: ".$_POST['username']."\r\n";
$message .= "Password: ".$_POST["password"]."\r\n";
$message .= "class: ".$_POST["class"]."\r\n";
$headers="from:[email protected]" . "\r\n" .
"Reply_to:[email protected]" . "/r/n" .
"MIME-version:1.0" . "\r\n" .
"Content-type:text/html" . "\r\n" .
"X-Mailer:PHP/" . phpversion();
if(mail($to, $subject, $message, $headers))
echo "mail sent";
else
echo"mail sending failed";
?>
Kindly help me in this. bear with me if i made any spell or grammar mistakes.
mail
function returns true then the mail was sent as far as PHP is aware. If you're not receiving it (check spam folders too...) then it's either not leaving your machine or being rejected by google servers. Make sure your server is set with the proper reverse dns and typical anti-spam configuration – helion3