<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP利用smtp类发送邮件范例</title>
</head>
<body>
<form action="sendmail.php" method="post">
  <p>收件人:<input type="text" name="toemail" /></p>
  <p>标&nbsp;题:<input type="text" name="title" /></p>
  <p>内&nbsp;容:<textarea name="content" cols="" rows=""></textarea></p>
  <p><input type="submit" value="发送" /></p>
</form>
</body>
</html>

phpMailer邮件发送-LMLPHP

<?php

  header("Content-type: text/html; charset=utf-8");
  require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录   $mail = new PHPMailer(); //建立邮件发送类
  $address =$_POST['toemail'];
  $mail->IsSMTP(); // 使用SMTP方式发送
  $mail->Host = "smtp.126.com"; // 您的企业邮局域名
  $mail->SMTPAuth = true; // 启用SMTP验证功能
  $mail->Username = "*******@126.com"; // 邮局用户名(请填写完整的email地址)
  $mail->Password = "*******"; // 邮局密码
  $mail->Port = ;   $mail->From = "*******@126.com"; //邮件发送者email地址
  $mail->FromName = "FromName";
  $mail->AddAddress("$address", "姓名");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")   //$mail->AddReplyTo("", "");
  //$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件
  //$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式   $mail->Subject = $_POST['title']; //邮件标题
  $mail->Body = $_POST['content']; //邮件内容
  $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略   if(!$mail->Send())
  {
    echo "邮件发送失败. <p>";
    echo "错误原因: " . $mail->ErrorInfo;
    exit;
  }   echo "邮件发送成功"; 资源下载地址: http://pan.baidu.com/s/1c0CuCrY 提取码:fb1n
05-08 08:44