邮件正文显示代码-PHPMailer

时间:2015-08-06 10:38:01

标签: php html anchor phpmailer

$mail->body = "<a href="www.example.com/register">Click here</a>";

我用这个用于phpMailer在邮件正文中创建一个链接。但它显示了这样的代码......

<a href="www.example.com/register">Click here</a>

怎么做......

2 个答案:

答案 0 :(得分:4)

$mail->Body

之后添加此内容
$mail->isHTML(); 

答案 1 :(得分:-1)

// PHP邮件功能

<?php
$to = "email@youremail.com";
            $subject = "Subject Should be here";
            $message="<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Welcome to Company Name!</title>
</head>

<body>
<div class='wrapper'>
    <div class='logo' style='margin-left:150px; margin-top:20px; float:left;'><a href='".$website."'><img src='".$website."images/logo.png' width='150'></a></div>
    <div class='msgtype' style='color: #fff;
    font-family: Arial,Helvetica,sans-serif;
    font-size: 30px;
    margin-left: 310px;
    margin-top: -82px; float:left;
    width: 500px;'>
    Welcome to Matchless Property.com ".$fullname."! 
    </div><div style='clear:both;'></div>
    <div class='ondate' style='margin-left:150px; margin-top:10px; font-family:Arial, Helvetica, sans-serif; color:#999; font-size:14px;'>".$date."</div>
    <div class='box' style='background-color:#eeeeee; margin-top:20px;'>
        <div class='note' style='margin-left:150px; padding-top:20px; font-family:Arial, Helvetica, sans-serif; font-size:28px; color:#333; width:650px; padding-bottom:20px;'>
        Welcome to Matchless Property! 
        </div>
        <div style='font-family:Arial, Helvetica, sans-serif; font-size:18; color:#666; margin-left:150px; margin-bottom:20px;'>
            <div>Hi, ".$fullname." Here it is notification mail from Matchless Property. Please verify your link below.</div>
        </div>
        <div class='forgotpassword' style='background-color: #33CCFF; padding: 6px 20px; width:85px; margin-bottom:20px; margin-left:130px;'>
            <a href='".$website."verification.php?uida56sdf4sd4f568er14dfv1=".$userRec['id']."' style='color: #FFFFFF;
    font-family: Arial,Helvetica,sans-serif;
    font-size: 18px;
    line-height: 28px;
    text-decoration: none;'>Click Here</a>
        </div>
        <div class='quitenote' style='margin-left:150px; padding-top:20px; font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#333; width:650px; padding-bottom:20px;'>
        You can now post ad and features! We are happy you are here.
        </div>
    </div>
    <div class='footer' style='background-color:#333; color:#999; font-family:Arial, Helvetica, sans-serif; padding:20px; text-align:center; font-size:12px;'>
        <a href='".$website."' style='color:#999; text-decoration:none;'>© Matchless Property</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='".$website."terms.php' style='color:#999; text-decoration:none;'>Terms & conditions</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='".$website."privacy.php' style='color:#999; text-decoration:none;'>Privacy policy</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='http://www.dimensionsxpert.com' style='color:#999; text-decoration:none;'>Dimensions Xpert</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='".$website."contact.php' style='color:#999; text-decoration:none;'>Contact us</a>
    </div>
</div>
</body>
</html>";

        // Always set content-type when sending HTML email
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

        // More headers
        $headers .= 'From: Company Name  <no-reply@matchlessproperty.com>' . "\r\n";
        $headers .= 'Bcc: yourname@youremail.com' . "\r\n";
        mail($to,$subject,$message,$headers);
?>