php邮件发送 phpmailer
首先要安装phpmailer开源项目。
将class.phpmailer.php转移到php文件夹下,
编写代码:
<?php require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录
$mail = new PHPMailer(); //建立邮件发送类
$address ="290248126@qq.com";
$mail->IsSMTP(); // 使用SMTP方式发送
$mail->Host = "smtp.qq.com"; // 您的企业邮局域名
$mail->SMTPAuth = true; // 启用SMTP验证功能
$mail->Username = "645564675@qq.com"; // 邮局用户名(请填写完整的email地址)
$mail->Password = "**********"; // 邮局密码
$mail->Port=25;
$mail->From = "645564675@qq.com"; //邮件发送者email地址
$mail->FromName = "轻风";
$mail->AddAddress("$address", "wuyou");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")
//$mail->AddReplyTo("", ""); //$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件
//$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式 $mail->Subject = "PHPMailer测试邮件"; //邮件标题
$mail->Body = "Hello,这是测试邮件"; //邮件内容
$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略 if(!$mail->Send())
{
echo "邮件发送失败. <p>";
echo "错误原因: " . $mail->ErrorInfo;
exit;
} echo "邮件发送成功"; /************************************************* 附件:
phpmailer 中文使用说明(简易版)
A开头:
$AltBody--属性
出自:PHPMailer::$AltBody
文件:class.phpmailer.php
说明:该属性的设置是在邮件正文不支持HTML的备用显示
AddAddress--方法
出自:PHPMailer::AddAddress(),文件:class.phpmailer.php
说明:增加收件人。参数1为收件人邮箱,参数2为收件人称呼。例 AddAddress("eb163@eb163.com","eb163"),但参数2可选,AddAddress(eb163@eb163.com)也是可以的。
函数原型:public function AddAddress($address, $name = '') {}
AddAttachment--方法
出自:PHPMailer::AddAttachment()
文件:class.phpmailer.php。
说明:增加附件。
参数:路径,名称,编码,类型。其中,路径为必选,其他为可选
函数原型:
AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream'){}
AddBCC--方法
出自:PHPMailer::AddBCC()
文件:class.phpmailer.php
说明:增加一个密送。抄送和密送的区别请看[SMTP发件中的密送和抄送的区别] 。
参数1为地址,参数2为名称。注意此方法只支持在win32下使用SMTP,不支持mail函数
函数原型:public function AddBCC($address, $name = ''){}
AddCC --方法
出自:PHPMailer::AddCC()
文件:class.phpmailer.php
说明:增加一个抄送。抄送和密送的区别请看[SMTP发件中的密送和抄送的区别] 。
参数1为地址,参数2为名称注意此方法只支持在win32下使用SMTP,不支持mail函数
函数原型:public function AddCC($address, $name = '') {}
AddCustomHeader--方法
出自:PHPMailer::AddCustomHeader()
文件:class.phpmailer.php
说明:增加一个自定义的E-mail头部。
参数为头部信息
函数原型:public function AddCustomHeader($custom_header){}
AddEmbeddedImage --方法
出自:PHPMailer::AddEmbeddedImage()
文件:class.phpmailer.php
说明:增加一个嵌入式图片
参数:路径,返回句柄[,名称,编码,类型]
函数原型:public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {}
提示:AddEmbeddedImage(PICTURE_PATH. "index_01.jpg ", "img_01 ", "index_01.jpg ");
在html中引用
AddReplyTo--方法
出自:PHPMailer:: AddRepl
*************************************************/ ?>
php邮件发送 phpmailer的更多相关文章
- PHP实现全自动化邮件发送 phpmailer
PHPmailer composer地址 function SendMail($msg,$theme,$content) { $mail = new \PHPMailer\PHPM ...
- 利用PHPMailer 来完成PHP的邮件发送 #转载自:大菜鸟在云端#
利用PHPMailer 来完成PHP的邮件发送 1.首先是下载PHPMailer http://code.google.com/a/apache-extras.org/p/phpmailer/ 2.解 ...
- phpMailer邮件发送
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 利用phpmailer类邮件发送
<?php require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录 $mail = new PHPMailer(); //建立邮 ...
- PHPMailer实现PHP邮件发送
1.首先是下载PHPMailer http://code.google.com/a/apache-extras.org/p/phpmailer/ 2.解压 从中取出class.phpmailer.ph ...
- Tp5.0 PHPMailer邮件发送
今天突然想起来邮件发送,就看了一下PHPmailer,其实这个用起来很简单,都是封装好的 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,把他放入TP5 ...
- TP5使用phpmailer实现邮件发送
1.从github下载PHPMailer,在vendor目录中新建文件夹phpmailer,将压缩包中的class.phpmailer.php和class.smtp.php复制到phpmailer中, ...
- 【Thinkphp 5】 整合邮箱类 phpmailer实现邮件发送
第一步:下载phpmailer文件,主要用到的文件只有箭头指向的两个,thinkphp5中,把class.phpmailer.php改成了phpmailer.php 第二步: 将phpmailer文件 ...
- TP5实现邮件发送(PHP 利用QQ邮箱发送邮件「PHPMailer」)
在 PHP 应用开发中,往往需要验证用户邮箱.发送消息通知,而使用 PHP 内置的 mail() 函数,则需要邮件系统的支持. 如果熟悉 IMAP/SMTP 协议,结合 Socket 功能就可以编写邮 ...
随机推荐
- touch——移动端
touch事件原生一定要用addEventListener来绑定 一.原生 touchstart:触摸开始时触发 touches:当前位于屏幕上所有手指的列表 event.touches.length ...
- 配置android source 在ubuntu中编译环境
在Ubuntu中可以配置 android source 编译环境,推荐使用最新的64位的Ubuntu LTS(Long Time Support); 1.安装JDK. AOSP主分支代码需要java ...
- linux安装缺失服务
sudo apt-get install ssh Reading package lists... Done Building dependency tree... Done Package ssh ...
- redirect_uri参数错误解决方法
坑,微信改来改去的,找死人了,以前在“开发者中心”中,现在改在”接口权限“中了.
- Jquery inArray的使用
var typeList=["A","B","C","D"]; if ($.inArray("A", ...
- IOS的segmentedControl(分段器控件)的一些常用属性
#pragma mark - 创建不同的分段器 //初始化方法:传入的数组可以是字符串也可以是UIImage对象的图片数组 UISegmentedControl *mysegmented = [[UI ...
- asp.net 异步处理
#region 异步测试 //委托 public delegate void PrintDelegate(string s); [WebMethod] public string yibu() { / ...
- OC_NSString
// // main.m // OC_NSString // // Created by qianfeng on 15/6/10. // Copyright (c) 2015年 qianfeng. A ...
- javascript异步执行函数导致的变量变化问题解决思路
for(var i=0;i<3;i++) { setTimeout(function(){ console.log(i) },0); }控制台输出:333 这是因为执行方法的时候for循环已经执 ...
- Walkthrough: Creating and Using a Dynamic Link Library (C++)
Original Link: http://msdn.microsoft.com/zh-cn/library/ms235636.aspx Following content is only used ...