发送验证邮件无效

时间:2014-05-01 23:15:10

标签: php email verification

我有一个PHP代码可以向用户发送验证邮件,但它不起作用。首先我把这段代码:

<?php

function Send_Mail($to,$subject,$body)
{
    require 'class.phpmailer.php';
    $from       = "**************@gmail.com";
    $mail       = new PHPMailer();
    $mail->IsSMTP(true);            // use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->Host       = "smtp.gmail.com"; // SMTP host
    $mail->Port       =  465;                    // set the SMTP port
    $mail->Username   = "**************@gmail.com";  // SMTP  username
    $mail->Password   = "***************";  // SMTP password
    $mail->SetFrom($from, 'From Name');
    $mail->AddReplyTo($from,'From Name');
    $mail->Subject    = $subject;
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, $to);
    $mail->Send();
}

$to      = 'piratapiton@gmail.com'; // Send email to our user
$subject = 'Signup | Verification'; // Give the email a subject
$message = '

Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.

------------------------
Username: '.$name.'
Password: '.$password.'
------------------------

Please click this link to activate your account:
http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'

'; // Our message above including the link

$headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from headers
Send_Mail($to, $subject, $message); // Send our email
?>

然后我下载了class.phpmailer.php并再试一次但是没有用。

我如何解决它?

0 个答案:

没有答案
相关问题