当前位置:

laravel 发送邮件

本文最后更新于2022-08-24,已超过 1年没有更新,如果文章内容、图片或者下载资源失效,请留言反馈,我会及时处理,谢谢!

温馨提示:本文共1097个字,读完预计3分钟。

文章目录
  • 发送文本邮件
  • 发送视图邮件#
  • 发送视图邮件文本附件#
  • 发送视图邮件图片附件#

本文出处:https://learnku.com/articles/64183

发送文本邮件

    $data = "测试发送";
    $from = "xxxx@qq.com";
    $name = "xxx";
    $title = "测试标题";
    $to = "xxxxx@qq.com";
    Mail::raw($data,function ($message) use($from, $name, $title, $to) {
   $message->from($from,$name);
   $message->to($to);
});

发送视图邮件#

   $from = "xxxxx@qq.com";
   $name = "xxx";
   $title = "测试";
   $to = "xxxxx@qq.com";
   $data = ["name" => "xxxxx"];
   Mail::send("welcome",$data,function ($message) use($from,$name,$title,$to) {
    $message->from($from,$name);
    $message->subject($title);
    $message->to($to);
 });

发送视图邮件文本附件#

  $from = "xxxxx@qq.com";
  $name = "xxxx";
  $title = "测试";
  $to = "xxxxxx@qq.com";
  Mail::send("welcome",[],function ($message) use($from, $name, $title, $to) {
   $message->from($from, $name);
   $message->subject($title);
   $message->to($to);
   $attachment = public_path("robots.txt");
   $message->attach($attachment,['as' => 'root.txt']);
 });

发送视图邮件图片附件#

  $from = "xxxxxxx@qq.com";
  $name = "xxxxx";
  $title = "测试";
  $to = "xxxxx@qq.com";
  $img = public_path("kato.jpeg");
  Mail::send("welcome",[],function ($message) use($from, $name, $title, $to,$img) {
   $message->from($from, $name);
   $message->subject($title);
   $message->attach($img);
   $message->to($to);
  });

本文链接:,转发请注明来源!
评论已关闭。