当前位置:网站首页>laravel 发送邮件
laravel 发送邮件
2022-04-23 20:43:00 【陈卿诺语】
laravel 邮件发送核心要点:需要用到Mail对象
1、首先要在邮箱中配置:开启 【POP3/SMTP服务】
生成密钥
2、在 .env 中配置
MAIL_MAILER=smtp
MAIL_HOST=smtp.qq.com
MAIL_PORT=465
[email protected]//你的发送邮件账号
MAIL_PASSWORD=//开启qq邮箱SMTP后获取的授权密码
MAIL_ENCRYPTION=ssl
[email protected]//你的发送邮件账号
MAIL_FROM_NAME="${APP_NAME}"
3、在控制器中操作:引入Mail对象
use Illuminate\Support\Facades\Mail;
4、添加邮件发送方法:
//直接文本发送
Mail::raw('测试邮件',function ($message){
$message->from('[email protected]//你的发送邮件账号','测试邮件');
$message->subject('hhhhhhhh');
$message->to('[email protected]//你的发送邮件账号');
});
$qq = '[email protected]//你的发送邮件账号';
//使用blade模板发送(引用的模板)
Mail::send('mailtest',['name' => 'test'],function($message)use($qq){
$message->to($qq)->subject('hhhhhhh');
});
5、如果使用blade模板发送,需要添加对应的blade模板,如上例就是在/view目录下添加mailtest.blade.php模板
<p>hello {
{$name}}</p>
版权声明
本文为[陈卿诺语]所创,转载请带上原文链接,感谢
https://blog.csdn.net/code_nutter/article/details/124356589
边栏推荐
- 堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
- 內網滲透之DOS命令
- MySQL 存储过程和函数
- Create vs project with MATLAB
- 一些接地气的话儿
- 【栈和队列专题】—— 滑动窗口
- go struct
- Case of the third day of go language development fresh every day project - news release system II
- Introduction to standardization, regularization and normalization
- 三十一. `prototype`显示原型属性和`__proto__`隐式原型属性
猜你喜欢
Unity solves Z-fighting
"Meta function" of tidb 6.0: what is placement rules in SQL?
On IRP from the perspective of source code
Leetcode 74. Search two-dimensional matrix
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
Rt-1052 learning notes - GPIO architecture analysis
[SQL] string series 2: split a string into multiple lines according to specific characters
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
vulnhub DC:1渗透笔记
随机推荐
Leetcode 74. Search two-dimensional matrix
6-5 string - 2 String copy (assignment) (10 points) the C language standard function library includes the strcpy function for string copy (assignment). As an exercise, we write a function with the sam
LeetCode 709、转换成小写字母
MySQL进阶之数据的增删改查(DML)
DOS command of Intranet penetration
Introduction to standardization, regularization and normalization
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
缓存淘汰算法初步认识(LRU和LFU)
How do BIM swindlers cheat? (turn)
C migration project record: modify namespace and folder name
LeetCode 232、用栈实现队列
bounding box iou
vulnhub DC:1渗透笔记
Fastdfs思维导图
Common form verification
Some basic knowledge of devexpress report development
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
Solution: NPM err! code ELIFECYCLE npm ERR! errno 1
JSX syntax rules
[stack and queue topics] - sliding window