我创建了一个表单,当我提交时,我会收到一封电子邮件。我使用过mailtrap和gmail,但两者都有效,但当我尝试使用自己的服务器电子邮件时,我收不到电子邮件。我知道代码有效,因为我之前使用过它。 我不知道这是否会影响为什么它不再工作但我必须在我的笔记本电脑上重新安装Windows并重新安装xampp。我还必须更改我用于服务器电子邮件的密码。
我的.env
MAIL_DRIVER=smtp
MAIL_HOST=lin01.hkdns.co.za
MAIL_PORT=587
MAIL_USERNAME=info@myserver.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=
我的mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'info@myserver.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
我的UsersController商店方法
public function store()
{
$users = new User();
$input = Input::all();
$validation = Validator::make($input, User::$rules);
if($validation->fails()){
return redirect()->route('admin.users.create')
->withInput()
->withErrors($validation)
->with('message', 'There were validation errors');
}
if($validation->passes()){
$users->name = Input::get('name');
$users->email = Input::get('email');
$users->image = Input::get('image');
$password = $users->generatePassword();
$users->password = bcrypt($password);
$data = array(
'name' => Input::get('name'),
'email' => Input::get('email'),
'password' => $password,
);
Mail::send('templates::emails.login', $data, function($message){
$message->to(Input::get('email'), Input::get('name'))->subject('Your login details');
});
$users->save();
$users = User::all();
return view('users::admin.index', compact('users'));
}
}
我的存储/日志中也没有出现错误