我試過使用郵件功能發送簡單的電子郵件,它工作。但是,當我嘗試將其插入到我的程序中時,它不會。有人可以告訴我哪個部分是錯誤的,因爲我非常確定它不是關於xampp/sendmail配置 - 我已經嘗試了2個簡單的郵件程序,除了這個之外,它們都工作。如何使此電子郵件確認工作?
我盡我所能把(...)代替不必要的行。我認爲問題在於,它不能進入prog讀電子郵件功能部分的部分?
這裏是我的register.php:
<?
session_start();
if(isset($_POST['register']))
{
include('/class.register.php');
$register = new Register();
if($register->process()) {
header('location: login.php');
}
else {
$register->show_errors();
}
}
?>
<form method= "POST" action="<?=$_SERVER['PHP_SELF'];?>">
<table>
<tr><td>Username:</td><td><input type="text" name="ruser" required="required" /></td></tr>
<tr><td>Email:</td><td><input type="text" name="remail" required="required" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="rpass" required="required" /></td></tr>
<tr><td>Title:</td><td><input type="text" name="rtitle" required="required" /></td></tr>
<tr><td>First Name:</td><td><input type="text" name="rfname" required="required" /></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="rlname" required="required" /></td></tr>
<tr><td>Mobile Number:</td><td><input type="text" name="rmobile" required="required" /></td></tr>
</table>
<input type="submit" name="register" value="Sign Up" />
</form>
這裏是我的class.register.php:
<?
class Register
{
...
private $errors;
public function __construct()
{
$this->errors = array();
...;
$this->token = $_POST['token'];
$this->passmd5 = md5($this->password);
}
public function process()
{
if($this->valid_data() && $this->send_email())
$this->register();
return count($this->errors)? 0: 1;
}
public function filter($var)
{
return preg_replace('/[^[email protected]]/','',$var);
}
public function user_exists()
{
...
}
public function email_exists()
...
public function register()
{
...
}
public function show_errors()
echo "<h3>Errors</h3>";
foreach($this->errors as $key=>$value)
echo $value."<br>";
public function valid_data()
...
public function send_email()
{
$from = '[email protected]';
$to = $_POST['remail'];
$subject = 'Registration confirmation';
$message = 'Please click the following link or copy and paste it
into your browser to complete the registration process: ';
$message .= 'http://example.com/confirm.php?u=';
$message .= urlencode($_POST['ruser']);
$message .= '&t=';
$message .= urlencode($_POST['token']);
return mail($to, $subject, $message, $from);
}
}
?>
您是否檢查過您的郵件日誌以查看是否有任何有用的信息? – bhttoan 2013-04-10 07:59:26
我有點不知道在哪裏檢查。呵呵 – 2013-04-10 08:30:03
我不使用Xampp,但它應該在\ xampp \ php \ logs中 - 尋找類似mail.log或php_mail.log的東西,並檢查這些文件的錯誤消息 – bhttoan 2013-04-10 08:34:29