我已经创建了一个自定义注册表格,我正在发送确认邮件,但显示错误
错误
无法启动进程[系统找不到路径 指定。]
控制器
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Http\Controllers\Controller;
use App\Contact;
use App\Student;
use App\Center;
use Illuminate\Support\Str;
use App\Mail\WelcomeMail;
use Illuminate\Support\Facades\Mail;
class MainpageController extends Controller
{
public function franchise_registration(Request $request)
{
$this->validate($request, [
'center_name' => 'required|string|max:255',
'center_head' => 'required|string|max:255',
'contact_no' => 'required|string|max:255',
'email' => 'required|string|max:255',
]);
$input['center_code'] ="KA_SIIT/".time();
$input['center_name'] = strtoupper ($request['center_name']);
$input['center_head'] = strtoupper ($request['center_head']);
$input['contact_no'] = $request->contact_no;
$input['email'] = $request->email;
Center::create($input);
Mail::to($input['email'])->send(new WelcomeMail($input));
return redirect('franchise')->with('success','YOUR REGISTRATION SUCCESSFULLY. .');
}
}
可邮寄
use App\Center;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class WelcomeMail extends Mailable {
use Queueable, SerializesModels;
public $user;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($user) {
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build() {
return $this->view('emails.confirmation');
}
}
邮件确认视图
<!DOCTYPE html>
<html>
<head>
<title>Welcome Email</title>
</head>
<body>
<h2>Welcome to the site {{$input['center_name']}}</h2>
<br/>
Your registered email-id is {{$input['email']}}
</body>
</html>
邮件驱动器
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=*********
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=null
答案 0 :(得分:1)
请确保邮件模板中没有$ input数组。
如果不是,请在邮件模板中使用$ user数组,因为您在__construct中传递了$ user。