我正在尝试在用户注册拉拉维尔后发送电子邮件。但是当我试图发送电子邮件时,我得到以下错误。我已经在env文件和配置文件/邮件.php文件中添加了所有配置。
以下是我在控制器中的代码
public function storeUsers(Request $request)
{
$postdata = $request->all();
$user = new User;
$hashedRandomPassword = Hash::make('password', [
'rounds' => 12
]);
$user = new User;
$user->name=$postdata['user_name'];
$user->email=$postdata['email'];
$user->password= $hashedRandomPassword;
$user->save();
Mail::to($postdata['email'])->send(new WelcomeMail($user));
return back()->with('success','thanks for contacting us');
exit(ok);
//Mail::to($postdata['email'])->send(new WelcomeMail($user));
// return $user;
//return redirect('users');
}
首先,我使用命令创建了邮件文件。以下是欢迎邮件中的代码.phpphp artisan make:mail WelcomeMail
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class WelcomeMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($user)
{
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
//return $this->from('xavierissac94@gmail.com')->subject('new customer registration')->view('emails.welcome');
return $this->view('emails.welcome')->with('data',$this->user);
}
}
为什么我得到这个错误请帮我
我收到以下错误
Swift_TransportException
Connection could not be established with host :stream_socket_client(): unable to connect to ssl://:0 (The requested address is not valid in its context.
)
慕田峪9158850
慕哥9229398