phpmailer

tp5.0发送邮件

白昼怎懂夜的黑 提交于 2019-12-03 22:51:45
1.从https://github.com/PHPMailer/PHPMailer网址下载PHPMailer类,将图片中的文件放到tp5.0里面的extend文件里面的PHPMailer里面的PHPMailer 2.在Index模板中的Index控制器中写下面的方法 < ? php namespace app\index\controller ; //引用相关的文件 use PHPMailer\PHPMailer\Exception ; use PHPMailer\PHPMailer\PHPMailer ; use PHPMailer\PHPMailer\ SMTP ; class Index { public function mail ( ) { $toemail = '3243280881@qq.com' ; //定义收件人的邮箱 $mail = new PHPMailer ( ) ; $mail - > isSMTP ( ) ; // 使用SMTP服务 $mail - > CharSet = "utf8" ; // 编码格式为utf8,不设置编码的话,中文会出现乱码 $mail - > Host = "smtp.qq.com" ; // 发送方的SMTP服务器地址 $mail - > SMTPAuth = true ; // 是否使用身份验证 $mail - >

tp5发送邮箱

五迷三道 提交于 2019-12-03 22:51:11
use phpmailer\phpmailer; /** * 发送邮箱 * @param type $data 邮箱队列数据 包含邮箱地址 内容 */ function sendEmail($data = []) { Vendor('phpmailer.phpmailer'); $mail = new PHPMailer(); //实例化 $mail->IsSMTP(); // 启用SMTP $mail->Host = 'smtp.126.com'; //SMTP服务器 以126邮箱为例子 $mail->Port = 465; //邮件发送端口 $mail->SMTPAuth = true; //启用SMTP认证 $mail->SMTPSecure = "ssl"; // 设置安全验证方式为ssl $mail->CharSet = "UTF-8"; //字符集 $mail->Encoding = "base64"; //编码方式 $mail->Username = 'ziyuanniao@126.com'; //你的邮箱 $mail->Password = 'xxxxxx'; //你的密码 $mail->Subject = '资源鸟系统提示'; //邮件标题 $mail->From = 'ziyuanniao@126.com'; //发件人地址(也就是你的邮箱) $mail-

Tp5.0 PHPMailer邮件发送

寵の児 提交于 2019-12-03 22:50:22
今天突然想起来邮件发送,就看了一下PHPmailer,其实这个用起来很简单,都是封装好的 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,把他放入TP5.0 框架的extend文件夹里面 在Controller里面创建一个文件Mail.php,代码如下 1 /* * 2 * Created by PhpStorm. 3 * User: luxiao 4 * Date: 2017/5/8 5 * Time: 11:23 6 */ 7 8 namespace app\index\controller; 9 10 use PHPMailer\PHPMailer\PHPMailer; 11 use PHPMailer\PHPMailer\ Exception ; 12 use think\Controller; 13 14 class Mail extends Controller 15 { 16 17 // 发送邮箱验证码 18 public function email() 19 { 20 $toemail = 'xxxxx@163.com'; // 定义收件人的邮箱 21 22 $mail = new PHPMailer(); 23 24 $mail->isSMTP(); // 使用SMTP服务 25 $mail->CharSet =

TP 通过STMP发送Email邮件

蓝咒 提交于 2019-12-03 22:50:11
1.下载PHPMailer文件,把文件放入ThinkPHP目录下的Vendor文件夹内 2.在项目的Common的function文件内写入公共函数 function SendMail ( $to , $title , $content ) { Vendor( 'PHPMailer.phpmailer' ) ; $mail = new PHPMailer() ; // 设置使用 SMTP 服务器发送邮件 $mail -> IsSMTP () ; // 启用 SMTP $mail -> Host = C( 'MAIL_HOST' ) ; //smtp 服务器的名称(这里以 QQ 邮箱为例) $mail -> SMTPAuth = C( 'MAIL_SMTPAUTH' ) ; // 启用 smtp 认证 $mail -> Username = C( 'MAIL_USERNAME' ) ; // 你的邮箱名 $mail -> Password = C( 'MAIL_PASSWORD' ) ; // 邮箱密码 $mail -> From = C( 'MAIL_FROM' ) ; // 发件人地址(也就是你的邮箱地址) $mail -> FromName = C( 'MAIL_FROMNAME' ) ; // 发件人姓名 $mail -> AddAddress ( $to , " 尊敬的客户

TP框架实现发送邮件

…衆ロ難τιáo~ 提交于 2019-12-03 22:49:36
1.在模块的配置文件config中加入下里面代码 'THINK_EMAIL' => array( 'SMTP_HOST' => 'SMTP.163.com', //SMTP服务器 'SMTP_PORT' => '465', //SMTP服务器端口 'SMTP_USER' => '156******83@163.com', //SMTP服务器用户名 'SMTP_PASS' => '********', //SMTP服务器密码 'FROM_EMAIL' => '156******83@163.com', //发件人EMAIL 'FROM_NAME' => 'demo', //发件人名称 'REPLY_EMAIL' => '', //回复EMAIL(留空则为发件人EMAIL) 'REPLY_NAME' => '', //回复名称(留空则为发件人名称) ), 2.在Common目录下创建function.php文件,加入下面代码 function think_send_mail($to, $name, $subject = '', $body = '', $attachment = null){ $config = C('THINK_EMAIL'); vendor('PHPMailer.class#phpmailer'); //从PHPMailer目录导class.phpmailer

tp5 邮件发送

假如想象 提交于 2019-12-03 22:49:20
1.先下载tp5发邮件扩展 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,在TP5框架的extend文件夹里面建一个PHPMailer文件夹 把下载下来的文件夹里边的src里边的 PHPMailer.php 和 SMTP.php 放在 刚刚创建的 TP5/extend/PHPMailer这个文件夹里 然后把 PHPMailer.php 和 SMTP.php 的命名空间改成 PHPMailer 然后在自己的方法里发送邮件就行了 public function setemail() { $mail = new PHPMailer(); $toemail = '196****107@qq.com';//收件人 $mail->isSMTP();// 使用SMTP服务 $mail->CharSet = "utf8";// 编码格式为utf8,不设置编码的话,中文会出现乱码 $mail->Host = "smtp.163.com";// 发送方的SMTP服务器地址 $mail->SMTPAuth = true;// 是否使用身份验证 $mail->Username = "187****535@163.com";/// 发送方的163邮箱用户名,就是你申请163的SMTP服务使用的163邮箱 $mail->Password = "******";

TP5实现发送邮件

妖精的绣舞 提交于 2019-12-03 22:48:54
记录一次邮件发送功能实现 使用 composer 安装 phpemailer 依赖 composer update phpmailer/phpmailer 发送携带附件的邮件 官方推荐代码 <?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; $mail = new PHPMailer(true); // Passing true enables exceptions try { //Server settings $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify

TP5 PHPMailer发送邮件代码

大城市里の小女人 提交于 2019-12-03 22:48:41
[TP5] PHPMailer发送邮件核心代码 PHPMailer 是一个用于发送电子邮件的PHP函数包。直接用PHP就可以发送,无需搭建复杂的Email服务。 首先启SMTP服务(使用PHP发送邮件需要用到SMTP服务 以QQ邮箱为例 如图:) 下载PHPMailer核心类 将下载好的文件放到application同级的vendor中(无需更改文件名直接放入即可 如图:) 放入文件后在application/common.php添加公共函数(可直接覆盖common.php 特殊使用者请自行CTRL+C/V) <?php use phpmailer\phpmailer; function sendEmail( $Host , $Password , $Subject , $From , $FromName , $data = []) { Vendor( 'phpmailer.phpmailer' ); $mail = new PHPMailer(); //实例化 $mail ->IsSMTP(); // 启用SMTP $mail ->Host = 'smtp.' . $Host . '.com' ; //SMTP服务器 以126邮箱为例子 $mail ->Port = 465; //邮件发送端口 $mail ->SMTPAuth = true; //启用SMTP认证 $mail -

tp5发送邮件

被刻印的时光 ゝ 提交于 2019-12-03 22:48:08
1.先下载tp5发邮件扩展 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,在TP5框架的extend文件夹里面建一个PHPMailer文件夹 把下载下来的文件夹里边的src里边的 PHPMailer.php 和 SMTP.php 放在 刚刚创建的 TP5/extend/ PHPMailer这个文件夹里 然后把 PHPMailer.php 和 SMTP.php 的命名空间改成 PHPMailer 然后在自己的方法里发送邮件就行了 public function setemail() { $mail = new PHPMailer(); $toemail = '196****107@qq.com';//收件人 $mail->isSMTP();// 使用SMTP服务 $mail->CharSet = "utf8";// 编码格式为utf8,不设置编码的话,中文会出现乱码 $mail->Host = "smtp.163.com";// 发送方的SMTP服务器地址 $mail->SMTPAuth = true;// 是否使用身份验证 $mail->Username = "187****535@163.com";/// 发送方的163邮箱用户名,就是你申请163的SMTP服务使用的163邮箱 $mail->Password = "******"

TP5 实现邮件发送

旧时模样 提交于 2019-12-03 22:47:36
在项目的开发中 用户修改密码,需要发送验证码到用户邮箱, 下载类库: 使用composer,项目目录下运行 composer require phpmailer/phpmailer common.php /** * 系统邮件发送函数 * @param string $tomail 接收邮件者邮箱 * @param string $name 接收邮件者名称 * @param string $subject 邮件主题 * @param string $body 邮件内容 * @param string $attachment 附件列表 * @return boolean */ function send_mail($tomail, $name, $subject = '', $body = '', $attachment = null) { $mail = new PHPMailer\PHPMailer\PHPMailer(); //实例化PHPMailer对象 $mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 0; // SMTP调试功能 0=关闭 1 = 错误和消息 2 = 消息 $mail-