phpmailer的简单使用

   html页面:
<form name="mail" id="mail" action="mail.php" method="post">
<table cellpadding="0" cellspacing="2" summary="加盟资料申请/培训内容资料申请">
<tr>
<th> 客户姓名:</th>
<td><input name="name" type="text" class="boxWB" /></td>
</tr>
<tr>
<th>单位地址(家庭地址):</th>
<td><input name="addr" type="text" class="boxWC" /></td>
</tr>
<tr>
<th>联系电话:</th>
<td><input name="tel" type="text" class="boxWA" /></td>
</tr>
<tr>
<th>电子邮箱:</th>
<td><input name="email" type="text" class="boxWB" /></td>
</tr>
</table>
<p><input name="submit" type="submit" value="提交"/></p>
</form>
php页面:
    require_once ("./PHPMailer/class.phpmailer.php");
    require_once ("./PHPMailer/class.smtp.php");
    require_once ("./PHPMailer/class.pop3.php");
    $type = isset($_POST['type']) ? $_POST['type'] : '';
    $name = isset($_POST['name']) ? $_POST['name'] : '';
    $addr = isset($_POST['addr']) ? $_POST['addr'] : '';
    $tel = isset($_POST['tel']) ? $_POST['tel'] : '';
    $email = isset($_POST['email']) ? $_POST['email'] : '';

    if (!empty($_POST)) {
            $mail = new PHPMailer();
            $mail->CharSet = "UTF-8";//字符集
            $mail->Encoding = "base64";
            $mail->IsSMTP();
            $mail->Host = "smtp.163.com";
            $mail->SMTPAuth = true;//smtp验证
            $mail->Username = "user";//163 126 的邮箱用户名
            $mail->Password = "password";//密码
            $mail->From = "cfanwzl@126.com"; //发件人 谁发出
            $mail->FromName = "客户加盟资料申请";
            $mail->AddAddress($email); //收件人  谁收到
      //  $mail->WordWrap = 50;
            $mail->IsHTML(true);
     //  $mail->Subject = "This Email From Customer ";
            $mail->Subject = "客户加盟资料申请";//标题
            $body = "客户名称: $name <br>";
            $body .= "联系地址: $addr <br>";
            $body .= "联系电话: $tel <br>";
            $body .= "Email: $name <br>";
            $body .= "需求资料: $type  <br>";   
            $mail->Body = $body;
          //  $mail->AltBody = "中文测试";

            if (!$mail->Send()) {
                    echo "Mailer Error" . $mail->ErrorInfo . '<br>';
                    echo "出错了";
            } else {
                    //echo "Mailer Success";
                    echo "<script type=\"text/javascript\"> alert('发送成功'); location=\"application.html\";</script>";
            }
    }else {
        echo "<script type=\"text/javascript\">  location=\"application.html\";</script>";
    }