Error: Laravel ao Enviar email

Asked

Viewed 2,249 times

0

When trying to send email in the Portuguese language I get this error message:

[Swift_transportexception]
Expected Response code 250 but got code "530", with message "530 5.7.1 Authentication required"

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD= xxxxx
MAIL_ENCRYPTION=tls

code Emailcron.php

<?php

namespace App\Mail;

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

class EmailCron extends Mailable
{
    use Queueable, SerializesModels;
    private $dados;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($dados)
    {
        $this->dados = $dados;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('corpoEmail')
                    ->to('[email protected]')
                    ->with(['dados' => $this->dados]);

    }
}

config/mail.php

<?php

return [


    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'smtp.gmail.org'),

    'port' => env('MAIL_PORT', 587),

    'from' => [
        'address' => '[email protected]',
        'name' => 'DEV',
    ],

    'encryption' => env('ssl', 'tls'),

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

    'sendmail' => '/usr/sbin/sendmail -bs',
];?>
  • How is your file config/mail.php?

  • I just edited the question with mail.php

  • Whenever I have that problem, I try to change MAIL_ENCRYPTION for ssl or leave it empty. Try this.

  • The error persists!

  • Dude, in the spirit of it, I think it would be cool for you to use an http://mailtrap.io of life to test emails, since you’re in a development environment...

  • You have to release in Gmail that the email does not have so many restrictions, here on the site already has answer for this if I’m not mistaken.

  • How do I do that? I edited the question with the values related to the mail

  • example: https://www.youtube.com/watch?v=-uOYk1AJpJ0

  • ideal explanation: https://learninglaravel.net/learn-to-send-emails-using-gmail-and-sendgrid-in-laravel-5

Show 4 more comments

3 answers

1

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=ssl

After you have to go in your gmail and enable for third party applications can do this sending.

So go into Login & Security and there at the end will see something like. inserir a descrição da imagem aqui

1


I use version 5.4 of laravel And I went through the same problem, set it up in gmail, with Hotmail, until I got a behavioral email, and nothing made that mistake go away, until I noticed documentation:

Driver Prerequisites

The API based drivers such as Mailgun and Sparkpost are often Simpler and Faster than SMTP Servers. If possible, you should use one of These drivers. All of the API drivers require the Guzzle HTTP library, which may be installed via the Composer package manager:

composer require guzzlehttp/guzzle

I did according to documentation and started to work here, I believe you are going through the same problem.

0

inserir a descrição da imagem aqui

Due to the restrictions of gmail cooporativo I was obliged to use my personal gmail account and enable my application access to send email.

In any case the code is functional sending emails to each 24-hour cycle as it is configured in cron

I answer the question: Enable gmail authorization to send email. Generally, the gmail user receives an email requesting blocking or authorization

Browser other questions tagged

You are not signed in. Login or sign up in order to post.