<!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. JavaBean转换为XML的源码

    package com.cmge.utils; import java.util.Iterator; import com.cmge.org.oa.bean.OADepartment; import ...

  2. ubuntu下查找某个文件的路径

    参考:ubuntu下如何查找某个文件的路径      http://blog.csdn.net/lieyanhaipo/article/details/17055667 在Ubuntu有时候会遇到记得 ...

  3. 【leetcode】Anagrams

    Anagrams Given an array of strings, return all groups of strings that are anagrams. Note: All inputs ...

  4. Android SDK打包

    2015年6月18日 14:38:49 星期四 eclipse: 1. 将写好的代码上传版本库 2. 删除 /bin/* 3. eclipse->project->clean... 4. ...

  5. perl 二维数组

    perl没有真正的二维数组,所谓的二维数组其实是把一维数组以引用的方式放到另外一个一维数组. 二维数组定义 : my @array1=([1,2],[3,4],[45,9],[66,-5]);     ...

  6. 4.openstack之mitaka搭建glance镜像服务

    部署镜像服务 一:安装和配置服务 1.建库建用户 mysql -u root -p CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* T ...

  7. Google推荐的图片加载库Glide介绍

    英文原文 Introduction to Glide, Image Loader Library for Android, recommended by Google 译文首发  http://jco ...

  8. 【linux】sudo su切换到root权限

    在用户有sudo权限但不知道root密码时可用 sudo su切换到root用户

  9. IOS - UITableView分批显示数据 实现点击加载更多

    Phone屏幕尺寸是有限的,如果需要显示的数据很多,可以先数据放到一个table中,先显示10条,table底部有一察看更多选项,点击察看更多查看解析的剩余数据.基本上就是数据源里先只放10条, 点击 ...

  10. XP/Win7下QTP11循环试用30天的破解方法

    XP/Win7下QTP11循环试用30天的破解方法. XP下:1.找到以下路径:C:\Documents and Settings\All Users\Application Data\SafeNet ...