TP5发送邮件
1,前提去qq邮箱开启smtp

2,生成授权码

2,发送短信给

3,附上代码

贴上代码如下
<?php
namespace app\mails\controller;
use \think\Controller;
use \think\Db;
Class Index{
//测试邮件
//phpmail
function index(){
$mail = new \PHPMailer\PHPMailer\PHPMailer;
//$tomail = input("post.tomail"); //接收邮件的地址
$tomail = "1832689811@qq.com";
$mail->SMTPDebug = 1;
$mail->isSMTP();//使用smtp[udp]发件,邮件的发送协议 网站是http协议[tcp/ip]
$mail->Host = 'smtp.qq.com';//smtp.163.com smtp.126.com
$mail->CharSet='UTF-8'; //gbk
//是否开启用户验证, 若发件提示login fail,说明password与username配置错误
$mail->SMTPAuth = true;//验证登陆
$mail->Username = "2791862162@qq.com";//你的QQ邮箱
//若是qq邮箱,则使用授权码作密码
$mail->Password = 'jknpqjjwcilkddii';
$mail->Port = 465 ;//邮件发送端口
//需要开启ssl数据传输
$mail->SMTPSecure = 'ssl';
//谁发送的邮件
$mail->setFrom('2791862162@qq.com', '辛姐');
//发送给谁
$mail->addAddress($tomail, '无夕子');
//可以发附件,附件路径为绝对路径
$mail->addAttachment('/favicon.ico');
//可以发网页
$mail->isHTML(false);
$mail->Subject = '我很爱你,大宝贝';
$mail->Body = '恭喜您,收到我的祝福';
$res = $mail->send();
}
}
?>
TP5发送邮件的更多相关文章
- TP5 发送邮件代码
发送邮箱邮件方法 /** * 系统邮件发送函数 * @param string $tomail 接收邮件者邮箱 * @param string $name 接收邮件者名称 * @param strin ...
- php发送邮件(TP5)
先百度搜索phpmailer 下载phpmailer函数包 放到/vendor/下,这是tp5扩展类库目录 然后你需要一个已经开启了SMTP服务的邮箱,作为发送者邮箱,QQ邮箱163邮箱是需要自己开 ...
- TP5实现邮件发送(PHP 利用QQ邮箱发送邮件「PHPMailer」)
在 PHP 应用开发中,往往需要验证用户邮箱.发送消息通知,而使用 PHP 内置的 mail() 函数,则需要邮件系统的支持. 如果熟悉 IMAP/SMTP 协议,结合 Socket 功能就可以编写邮 ...
- TP5使用PHPMAILER发送邮件
TP使用PHPMAILER发送邮件 1.申请一个SMTP服务的邮箱. 我申请的是smtp.163.com的服务,注意SMTP服务密码不是登陆密码,需要单独设置 2.下载phpmailer类库文件htt ...
- 发送邮件 tp5.1 5.0都可以,实测有效
https://www.cnblogs.com/zhensg123/p/8954175.html 博客文章少了个Expection.php 文件; common.php <?php // 应用公 ...
- tp5.1发送邮件
<?php namespace app\admin\controller; use think\Controller; use think\Request; use PHPMailer\PHPM ...
- TP5之发送邮件
1.下载扩展,vendor\phpmailer 文件结构: 2.话不多说,上代码 注意点: · 需要提前开通对应邮箱的SMTP服务 · $mail->Host = " & ...
- Tp5.0 PHPMailer邮件发送
今天突然想起来邮件发送,就看了一下PHPmailer,其实这个用起来很简单,都是封装好的 https://github.com/PHPMailer/PHPMailer,直接下载下来之后,把他放入TP5 ...
- 仿百度糯米TP5项目笔记
需求分析 系统三大模块 商家平台.主平台.前台模块 Thinkphp5.0实战 仿百度糯米开发多商家电商平台网盘下载 (2017-04-24 01:46:23) 转载▼ 第1章 课程简介 本章 ...
随机推荐
- Repeater每行绑定事件代码
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repea ...
- Webpack 打包优化之体积篇
谈及如今欣欣向荣的前端圈,不仅有各类框架百花齐放,如Vue, React, Angular等等,就打包工具而言,发展也是如火如荼,百家争鸣:从早期的王者Browserify, Grunt,到后来赢得宝 ...
- jenkins参数传递
官方说明:https://wiki.jenkins.io/display/JENKINS/Parameterized+Build 1.添加参数传递 参数类型解析: 2.在 Execute shell ...
- 【漫话DevOps】What is DevOps?
最近几年"DevOps"这个关键词经常出现在项目开发当中,特别是随着微服务/容器/cloud在项目中的大范围应用,你不想知道都很难.作为一个伴随CI/CD到DevOps一路走来的工 ...
- Django 多页面间参数传递用session方法(Django七)
由一个页面跳转至另一个页面可以有render中携带几个参数,如下:照上例便在跳转到homepage页面后使用传递的四个参数了 但问题是如何在由homepage跳转到其他页面时仍可以使用这四个参数呢?我 ...
- liunx之firewalld&SELinux
1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status f ...
- 《Java从入门到失业》第四章:类和对象(4.2):String类
4.2String类 这一节,我们学习第一个类:String类.String翻译成汉语就是“字符串”,是字符的序列.我们知道,在Java中,默认采用Unicode字符集,因此字符串就是Unicode字 ...
- 不定方程(Exgcd)
#include<cstdio> using namespace std; int x,y; inline int abs(int a){return a>?a:-a;} int e ...
- 预科班D6
2020.09.14星期一 预科班D6 学习内容: 自习 发布小游戏 1.配置网络 #查看当前ip ifconfig #关闭NetworkManager systemctl stop NetworkM ...
- zepto | 用事件委托去解决无法给新增添的DOM添加事件的问题
前段时间在做一个任务的时候,碰见了一个问题:zepto无法用on事件去监听新增加的dom事件.这个问题用live可解决, 但是live在ios下失效,为了解决这个问题,我采用了暴力的方法去解决,每次添 ...