Page 1 of 1

Mail () - error

Posted: Sat Aug 23, 2003 12:27 am
by asd
Hi everyone,
I try to use the mail() function to enable the user to send their acknowledgement of losing password to my email account. well i set the smtp in php.ini, still it is not working. The code is attached as below :-
Any help will be greatly appreciated. TQ :D

Code: Select all

<html>
  <head>
    <h2>
     User Login
    </h2>
    <form method=post action="emailForgetPw.php">
   </head>
  <body> 
   <b>
    <br>
     Username
     <br>
    </b>
    <input type=text size=15 name="username">
     <br>
      <b>
       Email
     </b>
    <br>
    <input type=text size=15 name="email">
    <br>
    <input type=submit name=submit value="Login">
    <input type=reset  name=reset  value="Clear">
    <br>
    
  
   </form>  
 </body>
</html>

Code: Select all

<?
$username   = $_POST&#1111;'username'];
$email   = $_POST&#1111;'email'];

if ($submit = "Login") 
&#123;
 
  mysql_connect("localhost", "admin", "123") or                
    die ("Could not connect to database");

  mysql_select_db("test") or
    dir ("Could not select database");   

$qry = mysql_query("select first_name,last_name,email from users where username='$username'
and email='$email'");
$fetch = mysql_fetch_row($qry);
 

if ($fetch > 0)&#123;
$first_name = $fetch&#1111;0];
$last_name = $fetch&#1111;1];
$email = $fetch&#1111;2];
&#125;
?>


<?php

$mailto = "Anusuriya <anusuriya_asd@yahoo.com>";
$subject = "Forget Password";
$message = "Hello!\n I have forgotten my password.Please reset my password.\n\n";
$message = $message."My name is $first_name.$last_name";
$extra = "From: $email\r\nReply-To: $email\r\n";
if(@mail($mailto, $subject, $message,$mailfrom))&#123;
						echo "You new password has been forwarded to your specified email account. ";
					&#125;
					else&#123;
						echo "Error! New password failed to be sent. Please contact portal master.\n";
					&#125;




?>

Posted: Sat Aug 23, 2003 5:03 am
by tylerdurden
What is your setup? Windows Server or Linux? Must be Windows or you wouldn't need smpt? First thing I'd try is whether you can send emails from php at all:

Code: Select all

mail("yourmail@yourhost.com","Test","  ");

Mail()

Posted: Sat Aug 23, 2003 11:49 pm
by asd
tylerdurden,
Thanks for your reply. I use my yahoo account to receive the emails, it is not working. The same thing happened when i used my own mail account. Actually, i am using my faculty mail server, where the php.ini is configured in the faculty's server. The testing is done in my pc at my office. TQ.