<!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. C# 毕业证书打印《六》

    整理思路,从新出发. 加载模版 public void loadtemplate(Label lable) { string p_tempateFile = @"fomate.xml&quo ...

  2. SaltStack之Master配置文件详解

    salt-master的配置文件位于/etc/salt/master,可用选项如下: #######################主配置 interface默认值:0.0.0.0(所有的网络地址接口 ...

  3. 【leetcode】 Permutation Sequence (middle)

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  4. 【XLL API 函数】 xlDefineBinaryName

    用于为 xltypeBigData XLOPER/XLOPER12 分配永久存储名称.用于定义 workbook 保存的位名称,并能在任何时候通过定义名称来访问. 函数原型 Excel12(xlDef ...

  5. .net在当前日期的基础上加一天

    比如今天是:2015-11-10 18:57:01,在这个基础上加一天,那么就是2015-11-11 18:57:01,代码如下: DateTime now_dt = DateTime.Now; ). ...

  6. osg设置相机参数,包括初始位置

    严重注意!!!以下设置必须在viewer.realize();之后,否则不起作用!!!! 设置相机的位置,可以通过CameraManipulator(一般是osgGA::TrackballManipu ...

  7. [Android Pro] CountDownTimer倒计时

    定时执行在一段时候后停止的倒计时,在倒计时执行过程中会在固定间隔时间得到通知(译者:触发onTick方法),下面的例子显示在一个文本框中显示一个30s倒计时: new CountdownTimer(3 ...

  8. python基础——map/reduce

    python基础——map/reduce Python内建了map()和reduce()函数. 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Pro ...

  9. java的基本结构

  10. 20145206邹京儒《Java程序设计》第7周学习总结

    20145206 <Java程序设计>第7周学习总结 教材学习内容总结 第十三章 时间与日期 13.1.1 时间的度量 ·即使标注为GMT(格林威治时间),实际上谈到的的是UTC(Unix ...