【发布时间】:2017-03-07 18:42:44
【问题描述】:
在论坛中长时间搜索后,我找不到对我的案例有用的解决方案。
我做了很多在 laravel 中发送电子邮件的功能,而且总是很好用。
这一次,我收到了一个错误,如下所示:
StreamBuffer.php 第 95 行中的 ErrorException:
stream_socket_enable_crypto():SSL 操作失败,代码为 1。OpenSSL 错误消息: 错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
这是我的 .env 文件
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:FMtA/k/okcPZB/HbWGbw5YiBM4EC3njxxLbgcdM1GrA=
APP_URL=http://localhost
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=myDB
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=suckerblood2010@gmail.com
MAIL_PASSWORD=<<Here_my_password>>
MAIL_ENCRYPTION=tls
MAIL_SENDER=Administration
这里是我发送邮件的函数(在控制器 Auth 中):
public function register(Request $request)
{
$this->validateLogin($request);
$token = hash('sha256', str_random(100) . time(), false);
$user = new User();
$user->email = $request->get('email');
$user->password = bcrypt($request->get('password'));
$user->remember_token = $token;
//$user->save();
$sent = Mail::send('auth.emails.createAccount', ['token' => $token], function ($m) use ($user) {
$m->from(getenv('MAIL_USERNAME'), getenv('MAIL_SENDER'));
$m->to($user->email, $user->email)->subject(config('constants.AccountCreated'));
});
if($sent == 1)
{
$msg = Lang::get('messages.EmailSent');
$this->showLoginForm($msg);
}
else
{
return redirect('/login')->withErrors([
'email' => Lang::get('messages.UserAddingError')
]);
}
}
我尝试将协议从 tls 更改为 ssl,甚至将 prot 从 587 更改为 465
我只有这个项目才有这个问题,我不明白为什么,尽管我做了所有的搜索......
有什么建议吗?
非常感谢:)
【问题讨论】:
标签: windows laravel email ssl laravel-5