PHPmailer发HTML邮件超链接点击无效
用phpmailer发送HTML邮件,,<?php
include_once("class.phpmailer.php");;
$formmail="[email protected]";
$subject = "实验";   
$smtp="smtp.126.com";
$username="[email protected]";
$password="**********";
$mail=new PHPMailer();
$mail->SMTPAuth = true;
$mail->Host=$smtp;
$mail->IsSMTP();
$mail->SMTPAuth=true;
$mail->Username=$username;
$mail->Password=$password;
$mail->From="[email protected]";
$mail->FromName="Souba激活";
$mail->Sender="[email protected]";
$mail->Subject =$subject;
$mail->IsHTML(true);
$mail->Body ="<a href='www.google.com' target='_blank'>google</a>";$mail->AddAddress($formmail);
if(!$mail->Send())
{
echo "发送失败";
}
else
{
echo "发送成功";
}
?>
可以发送成功的,,不过进邮箱打开邮件,,点击超链接无效,,、
求高手帮忙解决一下,,,谢谢

解决方案 »

  1.   

    好汉,请你复制出,点击后的链接。原因有如下:
    第一,你的链接不全啊。
    第二,极有可能未转义,使用如下语句。
    $mail->Body ="<a href='htt://www.google.com' target='_blank'>google</a>";
      

  2.   

    下面的代码可以,我试过<?php// example on using PHPMailer with GMAILinclude("class.phpmailer.php");
    include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded$mail             = new PHPMailer();
     
    $mail->IsSMTP();
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 465;                   // set the SMTP port$mail->Username   = "GMAIL username";  // GMAIL username
    $mail->Password   = "GMAIL password";            // GMAIL password$mail->From       = "GMAIL username";
    $mail->FromName   = "Webmaster";
    $mail->Subject    = "This is the subject";
    $mail->AltBody    = "This is the body when user views in plain text format"; //Text Body
    $mail->WordWrap   = 50; // set word wrap$mail->MsgHTML("<a href='www.google.com' target='_blank'>google</a>");$mail->AddReplyTo("GMAIL username");
    $mail->AddAddress("GMAIL  send to username","First Last");$mail->IsHTML(true); // send as HTMLif(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message has been sent";
    }?>
      

  3.   

    查看email的源码就会知道。
      

  4.   

      $mail->IsHTML(true);                 // 是否HTML格式邮件      $mail->CharSet="utf-8";    //设置邮件编码
          $mail->Subject = "注册开通";          //邮件主题
          $mail->Body    = "<a href='http://www.baidu.com'>点击此处开通</a>";        //邮件内容
          $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //邮件正文不支持HTML的备用显示我试过的有效,不知道你的为什么??
    我的是摘自:http://www.phpnewer.com/index.php/Ymgx/detail/id/1
    你也可以试试
      

  5.   

    绝大多数的邮件客户端,比如Outlook,都默认屏蔽邮件中的超链接功能,直接识别为垃圾邮件。