我試圖使用PHP郵件功能來允許一封電子郵件在用戶輸入郵件地址後發送給包含其密碼的用戶。我意識到安全性不是很好,因爲我通過電子郵件傳遞密碼,但我可以稍後再關注。現在,我只需要功能。看起來代碼正在工作,因爲我收到了我的成功信息,但我沒有收到任何電子郵件,有任何想法? 我使用的Joomla 3.0作爲XAMPP服務器解決方案包的一部分託管在Apache服務器上。我也將全局配置中的設置更改爲SMTP,因爲我在其他論壇上看到了這一點,但沒有運氣:(我想知道'本地主機'因素是否會導致問題?Joomla 3.0中的php郵件功能無法正常工作
我的表單操作代碼用戶輸入他們的電子郵件)是;
<?php
if (isset($_POST['submit']))
{
mysql_connect('localhost','root','') or die("Could not connect to database");
mysql_select_db('joomla_lifestyle') or die("Could not select database");
$email = $_POST['email'];
$sql = mysql_query("SELECT * FROM users WHERE Email ='$email'");
$result = mysql_num_rows($sql);
if ($result == 1)
{
$rows = mysql_fetch_array($sql);
$password = $rows['Password'];
$email = $rows['Email'];
$subject = "Password Request";
$header = "from: [email protected]";
$body = "Your Password is " . $password;
mail($email, $subject, $header, $body);
$msg = "An Email Containing the Password has been Sent to you!";
header("Location:/Joomla-Lifestyle/index.php?option=com_content&view=article&id=9&msg=$msg");
} else
{
$msg = "User doesn't exist, please try again.";
header("Location:/Joomla-Lifestyle/index.php?option=com_content&view=article&id=9&msg=$msg");
}
}
?>
好奇,有沒有理由不使用內置的新用戶電子郵件功能在註冊後發送用戶密碼? –
是的,我意識到這個功能是可用的,但我正在根據我的代碼進行評分,所以工作必須是原創的。 – user3266484