2013-11-25 47 views
-2

即時通訊使用Linux系統PHP的郵件功能不發送,代碼有問題

我試過在我的網站上測試郵件php腳本,它與該腳本一起使用。但由於某種原因,不是我的。有沒有人看到任何錯誤?

 $title = "Confirmation Required"; 
     $msg = "An email has been sent to you with a confirmation link and your password. Once clicking the link you will be asked to change your password and you will be ready to start earning!.<br><center><h2>The email was sent to <strong>$email</strong>.</h2></center><center>Go Check Your Email And Confirm Your Account</center><br>"; 

    $to = $email; 
    $subject = "Confirm New Account"; 
    $message = "<h2>Welcome</h2> <h4><a href='$siteUrl/confirm.php?key=$userId'> Click Here To Confirm Account </a></h4> Your login information.<br>Login: <strong>$email</strong> <br> Password: <strong>$userId</strong>"; 
$headers .= "X-Mailer: PHP \r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= 'To: Member <$email>' . "\r\n"; 
$headers .= 'From: <' . $adminEmail. '>' . "\r\n"; 
    mail($to,$subject,$message,$headers); 


    } // all good 

    echo "Mail sent OK"; 

    } 

這是我的php.ini文件

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
sendmail_path = /usr/sbin/sendmail -t; 
sendmail_from = [email protected] 
+0

您是在本地生活還是在您的機器上工作? –

+1

檢查'mail()'函數的repsonse值。它是「真」還是「假」? – TiMESPLiNTER

+1

你可以發佈你的所有代碼嗎?在上面發佈的內容中,沒有爲您發送電子郵件,因爲'$ email'變量尚未設置。我意識到你可能把這些代碼留下了,但我不確定你是否確定了它。 – Jacques

回答

0

也許,郵件服務器壞了。我之前遇到過這個問題,它正在工作,然後突然停止工作。請檢查此:PHP Mail just suddenly stop working

或者,它可能是您的郵件配置設置是錯誤的。

1

嘗試改變這一行:

$headers .= 'To: Member <$email>' . "\r\n"; 

要這樣:

$headers .= 'To: Member <' . $email . '>' . "\r\n";