且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么邮件laravel在登台服务器上不起作用?

更新时间:2023-08-22 21:40:16

打开config/mail.php,.env文件,并将您的电子邮件驱动程序设置为波纹管",

open config/mail.php, .env files and set your email driver as mail as bellow,

'driver' => env('MAIL_DRIVER', 'mail'), //you must set it in env file too

然后,您可以像下面这样发送电子邮件,请注意,emails.admin.member是电子邮件模板的路径,在示例代码中,laravel将在路径resources\views\emails\admin\member.blade.php

then you can send emails like bellow, note that emails.admin.member, is the path to your email template, in the example code, laravel will look for a blade template in the path, resources\views\emails\admin\member.blade.php

Mail::queue('emails.admin.member', $data, function($message) {
        $message->subject("A new Member has been Registered" );
        $message->from('noreply@mydomain.net', 'Your application title');
        $message->to('yourcustomer@yourdomain.com');
    });

Mail::send('emails.admin.member', $data, function($message) {
        $message->subject("A new Member has been Registered" );
        $message->from('noreply@mydomain.net', 'Your application title');
        $message->to('yourcustomer@yourdomain.com');
    });