0

当管理员添加用户时,我正在尝试向用户发送信息电子邮件。但我不知道如何干预管理面板中的用户页面?

例如:欢迎“ $user->name”,您的用户名是“$ user->username”,密码是“ $user->password”。

我想了很多。却无法进步。仍然无法发送任何电子邮件。我们有办法让航海者表格中的这个电子邮件系统更容易吗?

编辑:添加了注册控制器

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);
}
}
4

1 回答 1

0

在视图文件夹中创建电子邮件模板

电子邮件.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('/');
于 2018-04-12T09:40:23.257 回答