我正在尝试在管理员添加用户时向用户发送信息电子邮件。但我不知道如何在Adminpanel中干预用户页面?
例如:欢迎" $user->name
",您的用户名为" $ user->username
"并且您的密码是" $user->password
"。
我想了很多。但是无法进步。仍然无法发送任何电子邮件。我们是否有办法在航海家表中使这个电子邮件系统更容易?
编辑:添加了Registercontroller
public function register(Request $request)
{
$this->validation($request);
$customer = new Customer();
$customer->name = $request->name;
$customer->surname = $request->surname;
$customer->phone = $request->phone;
$customer->email = $request->email;
$customer->password = bcrypt($request->password);
$customer->description = $request->password;
$customer->save();
Auth::guard('customer')->login($customer);
Session::flash('success', __('messages.success'));
return redirect('/');
编辑:添加了CustomerObserve.php
<?php
namespace App\Helper\Observers;
use App\Customer;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Mail;
class CustomerObserve implements ShouldQueue
{
public function created()
{
$customer = Customer::latest();
Mail::send('user_login_informations', ['customer' => $customer], function($message) use($customer) {
$message->to($customer->email, $customer->name)
->subject('account update');
})->delay(30);
}
}
答案 0 :(得分:0)
在视图文件夹中创建电子邮件模板
<强> email.blade.php 强>
@section('content')
<h2>Hello {{ ucfirst($customer->name) }},</h2>
<p>
Your email '{{ $customer->email }}' and password {{ $customer->password }}.
</p>
@stop
审稿人控制器
$this->validation($request);
$customer = new Customer();
$customer->name = $request->name;
$customer->surname = $request->surname;
$customer->phone = $request->phone;
$customer->email = $request->email;
$customer->password = bcrypt($request->password);
$customer->description = $request->password;
$customer->save();
Auth::guard('customer')->login($customer);
Session::flash('success', __('messages.success'));
Mail::send('email', ['customer' => $customer], function($message) use($customer) {
$message->to($customer->email, $customer->name)
->subject('account update');
});
return redirect('/');