PHP邮件()在一种情况下工作,并在另一种情况下不工作
问题描述:
我有一个用户基。每当有新用户注册时,我都会通过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);
答
这是因为,在第二个代码。
$emailto = '$useremail';
$toname = '$username';
在你的第一个代码
$emailto = $useremail;
$toname = $username;
所以,你说的地方,相同的代码工作登记而不是密码休息。对 ? – Ravi
与上面 – soumyajyoti
几乎相同的代码** **几乎与**和** **相同。 – Ravi