M-K's avatar
Level 2

Send Email using Gmail - localhost

i got this error:

Swift_TransportException
Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. w9sm2062655wmi.0 - gsmtp
"

dev :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=myAccountPassword
MAIL_ENCRYPTION=null

controller:

public function sendEmail(){
    Mail::to("[email protected]")->send(new Invoice('somthing'));
}

mailable class:

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Invoice extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('Email.Order');
    }
}

Route:

Route::get('/sendEmail','mycontroller@sendEmail');

mail.blade.php:

<h1>welcome</h1>
  • 2-Step Verification is on
  • it's work fine with mailtrap.io configuration

any idea ?

0 likes
4 replies
M-K's avatar
Level 2

@ADAMPRICKETT - when i did i got this error:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

then i add this to config.mail.php

'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ],

and i got new error:

Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at
534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor d14sm4097234wro.79 - gsmtp
". Authenticator PLAIN returned Expected response code 235 but got code "534", with message "534-5.7.9 Application-specific password required. Learn more at
534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor d14sm4097234wro.79 - gsmtp
". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials d14sm4097234wro.79 - gsmtp
".

Please or to participate in this conversation.