为什么我的 laravel 没有在电子邮件中发送表单数据
why my laravel is not sending form data in email
我正在尝试将此数据发送到电子邮件
dynamic_email_template.blade.php
<p>Hi, This is {{ $data['name'] }}</p>
<p>I have some query like {{ $data['message'] }}.</p>
<p>It would be appriciative, if you gone through this feedback.</p>
但问题是收到的电子邮件中缺少 $data['name']
& $data['message']
在模型和控制器中,即使我收到此数据,我也已使用 dd($this->data)
检查过它
这是我的路线
Route::get('/sendemail', 'SendEmailController@index');
Route::post('/sendemail/send', 'SendEmailController@send')->name('send.mail');
我的控制器
public function send(Request $request)
{
$data = array(
'name' => $request->name,
'message' => $request->message
);
// dd($data);
Mail::to('hamzaqureshi401@gmail.com')->send(new SendMail($data));
return back()->with('success', 'Thanks for contacting us!');
}
我的模型
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendMail extends Mailable
{
use Queueable, SerializesModels;
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
dd($this->data);
return $this->from('scoops@creamery.pk')->subject('New Customer Equiry')->view('dynamic_email_template')->with('data', $this->data);
}
}
?>
我哪里做错了,如有帮助将不胜感激
如果你愿意可以试试
在 dynamic_blade
<p>Hi, This is {{ $name }}</p>
<p>I have some query like {{ $email }}.</p>
<p>It would be appriciative, if you gone through this feedback {{ $message1 }}.</p>
并且只使用控制器,除了使用模型 class
$data = array(
'name' => $request->name,
'email' => $request->email,
'message1' => $request->message
);
Mail::send('dynamic_email_template',$data, function ($message) {
$message->from('example@mail.com', 'Contact');
$message->to('example@mail.com')->subject('Contact');
});
return back()->with('success', 'Thanks for contacting us!');
我正在尝试将此数据发送到电子邮件
dynamic_email_template.blade.php
<p>Hi, This is {{ $data['name'] }}</p>
<p>I have some query like {{ $data['message'] }}.</p>
<p>It would be appriciative, if you gone through this feedback.</p>
但问题是收到的电子邮件中缺少 $data['name']
& $data['message']
在模型和控制器中,即使我收到此数据,我也已使用 dd($this->data)
检查过它
这是我的路线
Route::get('/sendemail', 'SendEmailController@index');
Route::post('/sendemail/send', 'SendEmailController@send')->name('send.mail');
我的控制器
public function send(Request $request)
{
$data = array(
'name' => $request->name,
'message' => $request->message
);
// dd($data);
Mail::to('hamzaqureshi401@gmail.com')->send(new SendMail($data));
return back()->with('success', 'Thanks for contacting us!');
}
我的模型
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendMail extends Mailable
{
use Queueable, SerializesModels;
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
dd($this->data);
return $this->from('scoops@creamery.pk')->subject('New Customer Equiry')->view('dynamic_email_template')->with('data', $this->data);
}
}
?>
我哪里做错了,如有帮助将不胜感激
如果你愿意可以试试 在 dynamic_blade
<p>Hi, This is {{ $name }}</p>
<p>I have some query like {{ $email }}.</p>
<p>It would be appriciative, if you gone through this feedback {{ $message1 }}.</p>
并且只使用控制器,除了使用模型 class
$data = array(
'name' => $request->name,
'email' => $request->email,
'message1' => $request->message
);
Mail::send('dynamic_email_template',$data, function ($message) {
$message->from('example@mail.com', 'Contact');
$message->to('example@mail.com')->subject('Contact');
});
return back()->with('success', 'Thanks for contacting us!');