thinkphp 发送邮件

<?php
class IndexAction extends Action {
 public function page(){
 require('class.phpmailer.php');
    $email =
'[email protected]';    
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "smtp.163.com";
    $mail->SMTPAuth = true;
    $mail->Username = "
[email protected]";
    $mail->Password = "52789534";
    $mail->Port=25;
    $mail->From = "
[email protected]";
    $mail->FromName = "郭晓湉";
    $mail->CharSet = 'utf-8';
    $mail->AddAddress($email);
    $mail->IsHTML(true);
    $mail->Subject = "欢迎来到郭晓湉的blog";
    $href = "
http://blog.csdn.net/XTQueen_up";
    $mail->Body  = '您好,欢迎来到我的博客!<p>请点击此链接访问:<a href="'.$href.'">'.$href.'</a>';
    $mail->Body .= "<br><br>如不能点击,请复制该链接到浏览器地址栏访问。";
    if(!$mail->Send())
    {
        echo "邮件发送失败。";
    }
    $_SESSION['send_time'] = time();
    echo "邮件发送成功。";
 }
}
?>

你可能感兴趣的:(thinkphp 发送邮件)