2017-06-18 191 views
0

我有一個用戶基。每當有新用戶註冊時,我都會通過php mail()向他們發送一封歡迎郵件。它工作得很好。這裏是代碼的郵件部分 -PHP郵件()在一種情況下工作,並在另一種情況下不工作

$emailto = $useremail; 
$toname = $username; 
$emailfrom = '[email protected]*****.com'; 
$fromname = '*****'; 
$subject = 'Welcome to ****'; 
$messagebody = 'Dear '.$name.'<br/><br/>Thank you for becoming a member in the family of <b>*******</b>.<br>Please enter your chosen <b>Username : '.$username.'</b> and the <b>Activation Code : '.$y.'</b> to complete your registration process.<br/><b/r> You can enter the details in the link: www.*****.com/reg_success.html<br/><b/r><b><i>The*****Team</b></i>'; 

$headers = 
    'Return-Path: ' . $emailfrom . "\r\n" . 
    'From: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" . 
    'X-Priority: 3' . "\r\n" . 
    'X-Mailer: PHP ' . phpversion() . "\r\n" . 
    'Reply-To: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" . 
    'MIME-Version: 1.0' . "\r\n" . 
    'Content-Transfer-Encoding: 8bit' . "\r\n" . 
    'Content-Type: text/html; charset=iso-8859-1' . "\r\n"; 
    $params = '-f ' . $emailfrom; 
$test = mail($emailto, $subject, $messagebody, $headers, $params); 

但幾乎相同的郵件()代碼,我用它來發送密碼重置鏈接。不管用。儘管代碼沒有拋出錯誤,但郵件並未交付。我已經檢查過註冊郵件正在完美和快速地工作。不在這裏。這裏是代碼

$pwrurl = "www.*****.com/reset_password.php?q=".$*****; 
    $emailto = '$useremail'; 
    $toname = '$username'; 
    $emailfrom = '[email protected]****.com'; 
    $fromname = '****'; 
    $subject = 'Password Change Request'; 
    $messagebody = 'Dear '.$name.'<br/><br/>We received a request to reset the <b> login password </b> of your account. <br/>If you have not made the request, please call us immediately as someone else might be trying to access your account. <br> If you have indeed requested the reset, please click on the following link to reset your login password: <br/>'.$pwrurl.'</br>Remeber the link will remain active for an hour.<br/><b/r><b><i>****</b></i>'; 

    $headers = 
     'Return-Path: ' . $emailfrom . "\r\n" . 
     'From: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" . 
     'X-Priority: 3' . "\r\n" . 
     'X-Mailer: PHP ' . phpversion() . "\r\n" . 
     'Reply-To: ' . $fromname . ' <' . $emailfrom . '>' . "\r\n" . 
     'MIME-Version: 1.0' . "\r\n" . 
     'Content-Transfer-Encoding: 8bit' . "\r\n" . 
     'Content-Type: text/html; charset=iso-8859-1' . "\r\n"; 
     $params = '-f ' . $emailfrom; 
    $test = mail($emailto, $subject, $messagebody, $headers, $params); 
+0

所以,你說的地方,相同的代碼工作登記而不是密碼休息。對 ? – Ravi

+0

與上面 – soumyajyoti

+0

幾乎相同的代碼** **幾乎與**和** **相同​​。 – Ravi

回答

6

這是因爲,在第二個代碼。

$emailto = '$useremail'; 
$toname = '$username'; 

在你的第一個代碼

$emailto = $useremail; 
$toname = $username; 
相關問題