Expected response code 250 but got code “530”, with message "530 5.7.1 Authentication required

前端 未结 7 1401
情深已故
情深已故 2020-12-24 01:29

I got stuck on this error I trying to configure SMTP mail on laravel

\"here

相关标签:
7条回答
  • 2020-12-24 02:07

    That is basically authentication error due to misconfiguration of email settings.

    Go to .env file

    change

    MAIL_DRIVER=smtp
    MAIL_HOST=mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null
    

    to

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.gmail.com    
    MAIL_PORT=465    
    MAIL_USERNAME=ENTER_YOUR_EMAIL_ADDRESS(GMAIL)    
    MAIL_PASSWORD=ENTER_YOUR_GMAIL_PASSWORD    
    MAIL_ENCRYPTION=ssl
    

    The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively. Login to your Google Account, Go to security settings and enable Allow Less Secure App switch button.

    After that go to your project root directory and run the following command:

    php artisan clear:cache && php artisan clear:config && php artisan config:cache
    

    . Please refer to

    this guide for assistance and clarification (Note: For MAIL_HOST use smtp.gmail.com)

    0 讨论(0)
  • 2020-12-24 02:08

    your mail.php on config you declare host as smtp.mailgun.org and port is 587 while on env is different. you need to change your mail.php to

    'host' => env('MAIL_HOST', 'mailtrap.io'),
    
    'port' => env('MAIL_PORT', 2525),
    

    if you desire to use mailtrap.Then run

    php artisan config:cache
    
    0 讨论(0)
  • 2020-12-24 02:18

    I see you have all the settings right. You just need to end the local web server and start it again with

    php artisan serve
    

    Everytime you change your .env file, you need tor restart the server for the new options to take effect.

    Or clear and cache your configuration with

    php artisan config:cache
    
    0 讨论(0)
  • 2020-12-24 02:19

    I believe this has been answered in some sections already, just test with gmail for your "MAIL_HOST" instead and don't forget to clear cache. Setup like below: Firstly, you need to setup 2 step verification here google security. An App Password link will appear and you can get your App Password to insert into below "MAIL_PASSWORD". More info on getting App Password here

    MAIL_DRIVER=smtp
    MAIL_FROM_ADDRESS=noreply@domain.com
    MAIL_FROM_NAME=DomainName
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=587
    MAIL_USERNAME=YOUR_GMAIL@gmail.com
    MAIL_PASSWORD=YOUR_GMAIL_CREATED_APP_PASSWORD
    MAIL_ENCRYPTION=tls
    

    Clear cache with:

    php artisan config:cache
    
    0 讨论(0)
  • 2020-12-24 02:20

    Yep, and if you have tried all the above solutions (what's more likely to happen) and none work for you, it may happen that Guzzle is not installed.

    Laravel ships mailing tools, by which is required the Guzzle framework, but it won't be installed, and AS OF the documentation, will have to install it manually: https://laravel.com/docs/master/mail#driver-prerequisites

    composer require guzzlehttp/guzzle
    
    0 讨论(0)
  • 2020-12-24 02:21

    If you want to use default mailtrip.io you don't need to modify mail.php file.

    1. Create account on mailtrip.io
    2. Go to Inboxes > My Inbox > SMTP Settings > Integration Laravel
    3. Modify .env file and replace all nulls of correct credentials:
    MAIL_HOST=smtp.mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null
    
    1. Run:
    php artisan config:cache
    

    If you are using Gmail there is an instruction for Gmail: https://stackoverflow.com/a/64582540/7082164

    0 讨论(0)
提交回复
热议问题