PHPmail 亲测可用
2017年5月8日9:10:47 1.在模块的配置文件中加入下里面代码,账号最好用126邮箱
'THINK_EMAIL' => array( 'SMTP_HOST' => 'smtp.163.com', //SMTP服务器 'SMTP_PORT' => '465', //SMTP服务器端口 'SMTP_USER' => 'ihtxt@126.com', //SMTP服务器用户名 'SMTP_PASS' => 'ihtxt.com', //SMTP服务器密码 'FROM_EMAIL' => 'wdxy@126.com', //发件人EMAIL 'FROM_NAME' => '沃德学院', //发件人名称 'REPLY_EMAIL' => 'wdxy@163.com', //回复EMAIL(留空则为发件人EMAIL) 'REPLY_NAME' => '沃德学院', //回复名称(留空则为发件人名称) ),
2.在模块的函数库中加入下面代码 function think_send_mail($to, $name, $subject = '', $body = '', $attachment = null){ $config = C('THINK_EMAIL'); vendor('PHPMailer.class#phpmailer'); //从PHPMailer目录导class.phpmailer.php类文件 $mail = new PHPMailer(); //PHPMailer对象 $mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 0; // 关闭SMTP调试功能 // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // 启用 SMTP 验证功能 $mail->SMTPSecure = 'ssl'; // 使用安全协议 $mail->Host = $config['SMTP_HOST']; // SMTP 服务器 $mail->Port = $config['SMTP_PORT']; // SMTP服务器的端口号 $mail->Username = $config['SMTP_USER']; // SMTP服务器用户名 $mail->Password = $config['SMTP_PASS']; // SMTP服务器密码 $mail->SetFrom($config['FROM_EMAIL'], $config['FROM_NAME']); $replyEmail = $config['REPLY_EMAIL']?$config['REPLY_EMAIL']:$config['FROM_EMAIL']; $replyName = $config['REPLY_NAME']?$config['REPLY_NAME']:$config['FROM_NAME']; $mail->AddReplyTo($replyEmail, $replyName); $mail->Subject = $subject; $mail->AltBody = "为了查看该邮件,请切换到支持 HTML 的邮件客户端"; $mail->MsgHTML($body); $mail->AddAddress($to, $name); if(is_array($attachment)){ // 添加附件 foreach ($attachment as $file){ is_file($file) && $mail->AddAttachment($file); } } return $mail->Send() ? true : $mail->ErrorInfo; } 3.下载mail插件解压到ThinkPHP/Library/Vendor目录中,再将PHPMail目录中的class.smtp.php复制一份到Vendor目录中并
重命名为SMTP.php
4.修改php.int文件
windows下在php.ini中去掉下面的分号 extension=php_openssl.dll 并将allow_url_fopen = Off改为 allow_url_fopen = On
5.在控制器中使用函数
$r = think_send_mail('要发送的邮箱','发送人名称,即你的名称','文件标题','邮件内容');
PHPmail 亲测可用的更多相关文章
- C#读取Excel设置(亲测可用)
OpenFileDialog openFD = new OpenFileDialog(); openFD.FileName = ""; openFD.Filter = " ...
- IntelliJ13+tomcat+jrebel实现热部署(亲测可用)
网上有很多介绍intellij idea整合jrebel插件实现热部署的文章,但是有的比较复杂,有的不能成功,最后经过各种尝试,实现了整合,亲测可用!步骤说明如下: 一.先下载jrebel安 ...
- Linux下通过crontab及expect实现自动化处理 --亲测可用
#!/usr/bin/expect -fspawn /home/scripts/bckup.shexpect "Enter password: " send "WWQQ ...
- 亲测可用!!!golang如何在idea中保存时自动进行代码格式化
亲测可用,golang在idea中的代码自动格式化 1.ctrl+alt+s打开设置界面,选择[Plugins] -> [Install JetBrains plugin...] -> 搜 ...
- Spring4.0.1+Quartz2.2.1实现定时任务调度[亲测可用]
Spring4.0.1+Quartz2.2.1实现定时任务调度[亲测可用] tip:只需要配置xml文件即可 1.第三方依赖包的引入 <properties> <project.bu ...
- Sublime Text3注册码,亲测可用
将以下复制在输入框即可 ,亲测可用 . 不过还是希望大家多多支持正版 . -– BEGIN LICENSE -– TwitterInc 200 User License EA7E-890007 1D7 ...
- IDEA 使用Mybatis效率飞起来的必备工具:MybatisCodeHelperPro 最新破解版,亲测可用!
IDEA 2018.3.5 最新版本亲测可用. Git地址:https://github.com/pengzhile/MyBatisCodeHelper-Pro-Crack/releases 下载最新 ...
- jetbrains的JetBrains PyCharm 2018.3.1破解激活到2100年(最新亲测可用)
破解补丁激活 之前看了好多的其它的方法感觉都不是很靠谱还是这个本人亲试可以长期有效不仅能激活pycharm.jetbrains的JetBrains PyCharm 2018.3.1破解激活到2100年 ...
- Cocos Creator JS web平台复制粘贴代码(亲测可用)
Cocos Creator JS web平台复制粘贴代码(亲测可用) 1 webCopyString: function(str){ var input = str; const el = docum ...
随机推荐
- HDU 1257 最少拦截系统(dp)
Problem Description 某国为了防御敌国的导弹突击,发展出一种导弹拦截系统.可是这样的导弹拦截系统有一个缺陷:尽管它的第一发炮弹可以到达随意的高度,可是以后每一发炮弹都不能超过前一发的 ...
- Robotium结果的收集和失败重跑
引用自 http://www.robotium.cn/archives/author/zered 测试用例: testsuite管理测试用例 测试结果的输出与收集? InstrumentationTe ...
- Codeforces Round #422 (Div. 2) E. Liar 后缀数组+RMQ+DP
E. Liar The first semester ended. You know, after the end of the first semester the holidays beg ...
- HBase在滴滴出行的应用场景和最佳实践
摘要: 主要介绍了HBase和Phoenix在滴滴内部的一些典型案例.文章已在CSDN极客头条和<程序员>杂志发表,应朋友邀请,分享到云栖社区,希望给大家带来启发和帮助. 背景 对接业务类 ...
- atomic_cmpxchg()/Atomic_read()/Atomic_set()/Atomic_add()/Atomic_sub()/atomi
[ 1.atomic_read与atomic_set函数是原子变量的操作,就是原子读和原子设置的作用.2.原子操作,就是执行操作的时候,其数值不会被其它线程或者中断所影响3.原子操作是linux内核中 ...
- POJ1759 Garland —— 二分
题目链接:http://poj.org/problem?id=1759 Garland Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- 跳转到AppStore 的不同位置办法
程序跳转到appstore中指定的应用 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat: ...
- codeforces 672A A. Summer Camp(水题)
题目链接: A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 机器学习 Hidden Markov Models 1
Introduction 通常,我们对发生在时间域上的事件希望可以找到合适的模式来描述.考虑下面一个简单的例子,比如有人利用海草来预测天气,民谣告诉我们说,湿漉漉的海草意味着会下雨,而干燥的海草意味着 ...
- 【前端】CentOS 7 系列教程之二: 安装 git 最新版
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_2.html 这一篇我们来安装git高版本. 卸载yum安装的旧版本 yum remove git 安装 ...