我想用laravel和vuejs发送电子邮件。我像下面这样写了laravel控制器函数
Mail::send(['text' => 'mail'],['name', 'David'], function($message){
$message->to('test123@gmail.com')->subject('Test Email');
$message->from('testmail@gmail.com', 'David');
});
return response()->json(['success'=>true]);
我为@click方法写了一个vuejs send email函数
this.axios.get('https://techwizlanka/send', {
body: JSON.stringify(this.user),
headers: {
'content-type': 'application/json',
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
.then(res => res.json())
.then(data => {
console.log("email sent");
})
.catch(err => console.error(err.toString()));
我将这个URL命名为
Route::get('/send', 'MailController@sendMail');
但是当单击“发送”按钮时,它会显示此错误消息。
app.js:44786未捕获TypeError:无法在VueComponent.sendMail (app.js:44786)的invoker (app.js:34769)的HTMLButtonElement.fn._withTask.fn._withTask (app.js:34568)读取未定义的属性“”get“”
有人能帮我解决这个问题吗?基本上,我想在提交带有laravel和vuejs的表单时发送电子邮件。
https://stackoverflow.com/questions/54248213
复制相似问题