英文:
Connection could not be established with host sandbox.smtp.mailtrap.io:stream_socket_client(): unable to connect to tsl://sandbox.smtp.mailtrap.io:587
问题
I see you want to test sending an email to a user using Mailtrap. To resolve the issue you mentioned in your code, it appears that there is a typo in your configuration. You have used "tsl" for encryption in your .env
file and should use "tls" instead. Here's the corrected part:
MAIL_ENCRYPTION=tls
After making this change, try sending the email again. If you encounter any further issues, please let me know.
英文:
Connection could not be established with host sandbox.smtp.mailtrap.io :stream_socket_client(): unable to connect to tsl://sandbox.smtp.mailtrap.io:587 (Unable to find the socket transport "tsl" - did you forget to enable it when you configured PHP?)
Why does it always show an error like this, even though I've changed the port to 465, 587, and 2525, and also switched the encryption from SSL to TLS
env.
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=8a0bd323485d04
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tsl
MAIL_FROM_ADDRESS=fiorezaradhinn@gmail.com
MAIL_FROM_NAME="milenialstuff.id"
config/mail.php
<?php
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
]
],
],
email view
@extends('layouts.app')
@section('css', '/css/email.css')
@section('title','Reset Password')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card-body">
<div class="judul">
<p>{{ ('Reset Password') }}</p>
</div>
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
<form method="POST" action="{{ route('password.email') }}">
@csrf
<div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="buttonsubmit">
{{ __('Send Password Reset Link') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
reset view
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('password.update') }}">
@csrf
<input type="hidden" name="token" value="{{ $token }}">
<div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="password" class="col-md-4 col-form-label text-md-end">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="password-confirm" class="col-md-4 col-form-label text-md-end">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Reset Password') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
I want to test sending an email to a user using Mailtrap.
答案1
得分: -1
请注意,加密方式的名称应该是 "tls" 而不是 "tsl"。在您的配置中,请将这一行 MAIL_ENCRYPTION=tsl
更新为 MAIL_ENCRYPTION=tls
。
以下是您配置的已校正版本:
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=8a0bd323485d04
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=fiorezaradhinn@gmail.com
MAIL_FROM_NAME="milenialstuff.id"
英文:
Please note that the name of the encryption should be "tls" instead of "tsl". In your configuration, update the line MAIL_ENCRYPTION=tsl
to MAIL_ENCRYPTION=tls
.
Here's the corrected version of your configuration:
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=8a0bd323485d04
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=fiorezaradhinn@gmail.com
MAIL_FROM_NAME="milenialstuff.id"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论