我已经ok ..在localhost中工作..邮件是从localhost发送的......但是当我把它上传到服务器时邮件没有来,也没有抛出异常......这是我的。 env文件代码
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mygmail@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
这是我的控制器代码
protected function create(array $data)
{
//dd($data);
$models = new User;
$user=User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
/*'usertype' =>$data['usertype'],*/
'status' => 0,
]);
$use = array('name' => 'Admin');
//$models->emailw = Auth::user()->email;
$message_id = "";
$name = "";
Mail::send('emailMessage', $use, function ($m) use ($message_id,$name){
$message_id = DB::getPdo()->lastInsertId();
$name = DB::table('users')->select('name')->where('id','=', $message_id)->pluck('name');
//$email = DB::table('users')->select('email')->where('id','=', $message_id)->pluck('email');
$subject = "Id = ". $message_id . " name = " .$name[0];
$m->to('mrbbangladesh2017@gmail.com')
->subject($subject);
});
return $user;
}
这是我的mail.php代码
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => [
'address' => 'admin@mrbglobalbd.com',
'name' => 'Admin',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
我需要在这里改变什么?
答案 0 :(得分:0)
在你的情况下,可能有许多事情可能出错。我尝试列出所有可能的选项:
我希望它有所帮助