gpt4 book ai didi

php - 预期响应代码 250 但得到代码 "554",消息“554 消息被拒绝 | Laravel 使用 TO 电子邮件

转载 作者:行者123 更新时间:2023-12-04 13:27:58 25 4
gpt4 key购买 nike

  • Laravel 版本:8.27
  • PHP版本$ php --version : PHP 8.0.3 (cli)
  • 数据库驱动程序和版本 $ mysql --version : mysql Ver 8.0.23-0ubuntu0.20.04.1

  • 问题陈述:
    我收到 TO 电子邮件在 FROM 电子邮件,当然不会在亚马逊 SES 中验证 POST password/email .

    说明:
    Let to@example2.com 将通过电子邮件询问密码重置链接。一般来自@example1.com 会发送密码重置链接。但是,就我而言, to@example2.com 正在尝试向自己发送密码重置链接。
    在 Amazon SES 中,我们需要验证电子邮件才能通过 SES 服务发送邮件。所以我已经从@example1.com 进行了验证。

    Note: Both domain are different example1.com and example2.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: to@example2.com "



    配置:
    $ 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="from@example2.com"
    MAIL_FROM_NAME="foo"

    最佳答案

    在我看来,您的 AWS 邮件服务或 Laravel 设置不正确
    https://aws.amazon.com/premiumsupport/knowledge-center/ses-554-400-message-rejected-error/
    您可以尝试使用开箱即用的 mailtrap.io 来测试内容。
    当应该发送电子邮件的服务器拒绝它时,通常会引发这种异常。通常是 SMTP 或 AWS SES 的情况。您还可能尝试通过 SMTP 通过 Outlook 帐户发送邮件,而安全策略不允许您发送邮件。
    但是,如果我做对了,您希望像人们自己发送电子邮件一样发送电子邮件。这是不可能的,因为您无法验证所有电子邮件。 *@*作为解决方案,您可以使用 reply-to选项,或 no-reply如果您不希望用户能够回复,则作为发件人。
    如果您不想以 to@ 的身份发送邮件,而是 from@确保 MAIL_FROM_EMAIL 在 env 中正确设置。
    电子邮件不应以未加密方式发送
    要使用的电子邮件端口:

    Protocol    Security Setting    Port Number(s)
    SMTP (sending mail) Encrypted - TLS/STARTTLS 465
    SMTP (sending mail) Encrypted - SSL 465
    SMTP (sending mail) Unencrypted 25* (or 26)

    POP3 (receiving mail) Encrypted - TLS 995
    POP3 (receiving mail) Encrypted - SSL 995
    POP3 (receiving mail) Unencrypted 110
    IMAP (receiving mail) Encrypted - TLS 993
    IMAP (receiving mail) Encrypted - SSL 993
    IMAP (receiving mail) Unencrypted 143
    https://billing.precedence.com.au/billing/knowledgebase/70/Mail-Ports-for-POP3-IMAP-and-SMTP.html

    关于php - 预期响应代码 250 但得到代码 "554",消息“554 消息被拒绝 | Laravel 使用 TO 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66981531/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com