Blogger Information
Blog 7
fans 0
comment 0
visits 15452
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Laravel-Mail(发送邮件)
冷雨画桥
Original
2437 people have browsed it

配置修改

  1. /**
  2. *./config/mail.php
  3. *./env
  4. *email配置
  5. */
  6. MAIL_DRIVER=smtp //引擎
  7. MAIL_HOST=smtp.exmail.qq.com //主机
  8. MAIL_PORT=465 //邮件端口
  9. MAIL_USERNAME=****@****.com //用户名
  10. MAIL_PASSWORD=****** //密码
  11. MAIL_ENCRYPTION=SSL //加密方式
  12. MAIL_FROM_ADDRESS=******@*****.com //邮件地址
  13. MAIL_FROM_NAME="邮件名称" //邮件名称

发送纯文本邮件

  1. //发送文本
  2. Mail::raw('文件内容',function($message){
  3. $message->from('******@***.com','发件人名称');
  4. $message->subjuect('文件标题');
  5. $message->to('********@***.com');//收件人
  6. });

发送html邮件

  1. //发送HTML
  2. /**
  3. *Mail::send('html模板','参数/值',function($message){
  4. #....
  5. })
  6. */
  7. Mail::send('blade',['data'=>$data],function($message){
  8. $message->from('******@***.com','发件人姓名');
  9. $message->subject('文件标题');
  10. $message->to('*******@***.com');
  11. }

发送附件邮件

  1. //发送附件--发送附件若文件路径在闭包函数外部 需 use ($path) 闭包内调用attach
  2. $path = "url";
  3. Mail::send('blade',['data'=>$data],function($message) use ($path){
  4. $message->from('***@***.com','发件人姓名');
  5. $message->subject('文件标题');
  6. $message->attach($path);//多个附件 需多次调用attach 如$message->attach($path2);
  7. $message->to('***@***.com');
  8. )
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post