Re: Problem sending email via php script | |
Why do you need to use smtp authentication ?
And, you have code missing in rtreiving the password from the DB.
Use this:
<?php
if (isset($_POST['Email'])) {
$db_host= "localhost";
$db_user = "XXXX_YYYYY";
$db_password = "ZZZZZZ";
$db_name ="XXXX_StudyKitchenData";
$db = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $db);
$userId = $_POST['Email'];
$sql = "SELECT Password FROM UserDetails WHERE Email = '$userId'";
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$Password = $row[Password];
// The above lines of code has been used in my other pages and it works fine
if (mysql_num_rows($result) == 1) {
$mailto = $userId;
$mailsubject = "StudyKitchen Password";
$mailbody = "Your study kitchen password is '$Password' ";
$mailheader = "From: Webmaster-StudyKitchen<webmaster@studykitchen.com>\r\n"
. "MIME-Version: 1.0"."\r\n"
. "Content-Type: text/plain; charset=utf-8"."\r\n"
. "Content-Transfer-Encoding: 8bit"."\r\n"
. "X-Mailer: PHP v".phpversion();
if(!mail($mailto, $mailsubject, $mailbody, $mailheader))
{
echo "<p>Mail not sent for unknown reason </p>";
}
else {
echo"<p>Your password successfully sent!</p>";
}
}
mysql_close($db);
}
?>
Didn't test it, but it should work.
__________________
Navaldesign Logger Lite: Low Cost, Customizable, multifeatured Login script Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more.... Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA! |