- Laravel Version: 8.27
- PHP Version
$ php --version
: PHP 8.0.3 (cli) - Database Driver & Version $
mysql --version
: mysql Ver 8.0.23-0ubuntu0.20.04.1
Problem Statement:
I'm getting TO
email in FROM
email which of course will not be verified in Amazon SES in POST
password/email
.
Description:
Let [email protected] will ask for Password Reset Link via email. Generally [email protected] will send password reset link. However, In my case [email protected] is trying to send password reset link to itself.
In Amazon SES we need to verify email to send mail through SES service. So I've verified [email protected].
Note: Both domain are different
example1.com
andexample2.com
.example1.com
is setup on Amazon SES.
Exception:
Swift_TransportException (554)
Expected response code 250 but got code "554", with message "554 Message rejected: Email address is not verified. The following identities failed the check in region REGION: [email protected] "
Configuration:
$ php artisan route:list
+--------+----------+-----------------------------------------------+------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------------------------------+------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------+
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web |
App\Http\Controllers\Auth\ForgotPasswordController.php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
vendor\laravel\ui\auth-backend\SendsPasswordResetEmails.php
namespace Illuminate\Foundation\Auth;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
trait SendsPasswordResetEmails
{
public function sendResetLinkEmail(Request $request)
{
$this->validateEmail($request);
$response = $this->broker()->sendResetLink(
$this->credentials($request)
);
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($request, $response)
: $this->sendResetLinkFailedResponse($request, $response);
}
vendor\laravel\framework\src\illuminate\Auth\Passwords\PasswordBroker.php
namespace Illuminate\Auth\Passwords;
use Closure;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Support\Arr;
use UnexpectedValueException;
class PasswordBroker implements PasswordBrokerContract
{
public function sendResetLink(array $credentials, Closure $callback = null)
{
$user = $this->getUser($credentials);
if (is_null($user)) {
return static::INVALID_USER;
}
if ($this->tokens->recentlyCreatedToken($user)) {
return static::RESET_THROTTLED;
}
$token = $this->tokens->create($user);
if ($callback) {
$callback($user, $token);
} else {
$user->sendPasswordResetNotification($token);
}
return static::RESET_LINK_SENT;
.env
MAIL_DRIVER="smtp"
MAIL_HOST="test-smtp.region.amazonaws.com"
MAIL_PORT="25"
MAIL_USERNAME="USER..."
MAIL_PASSWORD="PASS..."
MAIL_ENCRYPTION="tls"
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="foo"