<!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>

<?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

phpMailer邮件发送的更多相关文章

  1. Tp5.0 PHPMailer邮件发送

    今天突然想起来邮件发送,就看了一下PHPmailer,其实这个用起来很简单,都是封装好的 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,把他放入TP5 ...

  2. 关于phpmailer邮件发送

    今天有个需求,要把phpmailer集成到框架里面 所以我去官方下载了 phpmail5.2.6 地址在 https://github.com/PHPMailer/PHPMailer/releases ...

  3. 关于 PHPMailer 邮件发送类的使用心得(含多文件上传)

    This is important for send mail PHPMailer 核心文件 class.phpmailer.php class.phpmaileroauth.php class.ph ...

  4. (Swiftmailer)高效的PHP邮件发送库

    Swiftmailer是一个类似PHPMailer邮件发送组件,它也支持HTML格式.附件发送,但它发送效率相当高,成功率也非常高,很多PHP框架都集成了Swiftmailer. Swiftmaile ...

  5. 利用PHPMailer 来完成PHP的邮件发送 #转载自:大菜鸟在云端#

    利用PHPMailer 来完成PHP的邮件发送 1.首先是下载PHPMailer http://code.google.com/a/apache-extras.org/p/phpmailer/ 2.解 ...

  6. php邮件发送 phpmailer

    首先要安装phpmailer开源项目. 将class.phpmailer.php转移到php文件夹下, 编写代码: <?php require("class.phpmailer.php ...

  7. 利用phpmailer类邮件发送

    <?php require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录 $mail = new PHPMailer(); //建立邮 ...

  8. PHPMailer实现PHP邮件发送

    1.首先是下载PHPMailer http://code.google.com/a/apache-extras.org/p/phpmailer/ 2.解压 从中取出class.phpmailer.ph ...

  9. TP5使用phpmailer实现邮件发送

    1.从github下载PHPMailer,在vendor目录中新建文件夹phpmailer,将压缩包中的class.phpmailer.php和class.smtp.php复制到phpmailer中, ...

随机推荐

  1. js apply 和 call

    http://www.cnblogs.com/KeenLeung/archive/2012/11/19/2778229.html

  2. pl/sql中having的用法

    HAVING的作用: 因为where关键字无法与聚集函数一起使用,HAVING可以和聚集函数一起使用 HAVING的语法: SELECT column_name, aggregate_function ...

  3. iOS gcd dispatch使用注意,dispatch_syn可能产生的死锁

      我们在使用dispatch_sync 时可能会出现死锁,看下面的例子: import UIKit class ViewController: UIViewController { var seri ...

  4. Linux集群配置ntp时间同步服务

    集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase,当时间差别过大时就会挂掉,所以在大数据集群中,ntp服务,应该作为一种基础的服务,以下在演示在CentOS 7. ...

  5. Es6 学习笔记

    变量 let let用来声明变量,作用和var类似,所声明的变量只在let生命的代码块内有效. //1.不允许重复声明 let num = 2; let num = 3; //error //2.块级 ...

  6. jquery stop( ) 的用法 (转)

    目的:为了 了解stop()的用法,举个例子,直观的方式看看. 实物:一个id="animater"的div包含了一段文字.(以下用animator表示实物) 动画最终的完整效果: ...

  7. 【python】词法语法解析模块ply

    官方手册:http://www.dabeaz.com/ply/ply.html 以下例子都来自官方手册: 以四则运算为例: x = 3 + 42 * (s - t) 词法分析: 需要将其分解为: 'x ...

  8. NEFU 506&&ZOJ 3353 Chess Board (四种构造的高斯消元)

    题目链接 题意:有四种翻转方式,问是否能使得所有棋子都变为0,求最小步数. 题解:依次构造枚举求出最小值即可. #include <iostream> #include <cstdi ...

  9. Please see the 'svn upgrade' command

    svn: E155036: Please see the 'svn upgrade' command svn: E155036: Working copy '/home/easwy/dev' is t ...

  10. PHP try catch

    本文转载自百度知道 http://zhidao.baidu.com/link?url=Wi5EOXIf12yBp9d_4VoFHCUFtlTPcZJ0sxidLspV6P7qAqYMap3IC6dXE ...