当前位置:网站首页>PHP laravel8 send email

PHP laravel8 send email

2022-06-11 06:16:00 Results of persistence and effort

First step

The second step

  The third step stay .env The following are found in the configuration

Step four Plain text mode

Step five Rich text mode

 
 
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;
// Introduce these two classes , This is a laravel8 Self contained 
 
//send  The first parameter is the template file , Because it's rich text mail , The template file is placed in resources->views  Next 
//send  The second parameter is the variable to be passed into the template , Template variables must be arrays 
//send  The third parameter is who to send and what the subject is 
Mail::send('admin.mail.mail',$array,function (Message $message) use ($array){
                // To whom , Real email address 
                $message->to($array['email']);
                // Send theme 
                $message->subject(' email ');
            });

 

  Rich text sending

\Mail::send('admin.email.email',['name'=>$user['name']] ,function ($message) use ($user) {
            $message->to(" Email sent ");
            $message->subject(' This is the message ');
        });

原网站

版权声明
本文为[Results of persistence and effort]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020528544064.html