<!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. phpcms分页用法简介

    PHPCMS分页的用法 前面需要有引用的list,代码如下: {pc:content action="lists" catid="11" order=" ...

  2. java的事务处理

    本文转自http://zhenchengchagangzi.iteye.com/blog/1159493 java的事务处理,如果对数据库进行多次操作,每一次的执行或步骤都是一个事务.如果数据库操作在 ...

  3. git diff获取差异文件中文乱码的解决办法

    通过git的diff命令对两个commit id的版本进行差异化的对比.中文文件时出现乱码. git diff 6bded8d0c1fe1746c122121217dc0c88667091089 a9 ...

  4. ios8 新增的 showViewController 和 showDetailViewController

    1.showViewController 先看看说明: You use this method to decouple the need to display a view controller fr ...

  5. FFmpeg-20160413-snapshot-bin

    ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 F ...

  6. openal-1.13 静态编译(mingw32)

    1.CMakeLists.txt SET(LIBTYPE SHARED) 改成 SET(LIBTYPE STATIC) 2.include/al/al.h 删除 dllexport 3.include ...

  7. Common Knowledge_快速幂

    问题 I: Common Knowledge 时间限制: 1 Sec  内存限制: 64 MB提交: 9  解决: 8[提交][状态][讨论版] 题目描述 Alice and Bob play som ...

  8. Binary String Matching

    问题 B: Binary String Matching 时间限制: 3 Sec  内存限制: 128 MB提交: 4  解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...

  9. JS 基本语句

    1.循环中必备的条件: 初始值  循环条件  状态改变   循环体 for(初始值  循环条件  状态改变)    {       循环体     } for(var i=0;i<100;i++ ...

  10. HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场

    题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题 ...