Error sending email on Laravel 5.7 - Swift_transportexception

Asked

Viewed 1,942 times

-1

Hello,

I’m trying to send an email using Laravel 5.7, and I had some problems.

I wrote a view for my email. Then I send the email rendered by the Controller, as follows:

Mail::send('admin.eventos.pessoa', ['pessoa' => $pessoa], function ($message) use ($pessoa){
   $message->to($pessoa->email);
});

I configured my email in Laravel as follows, the way I always do in test applications:

MAIL_DRIVER=smtp
MAIL_HOST=mx1.hostinger.com.br
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=senha
MAIL_ENCRYPTION=tls

In addition, I configured the mail.php file to resolve the previous 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", as described the English version of the OS.

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

Well, then I call the controller method that calls this first snippet that I put to the question. This controller is called via Post. But instead of the email being sent, I get this as a response:

Swift_transportexception thrown with message "Expected Response code 354 but got code "554", with message "554 5.5.1 Error: no Valid Recipients ""

What can it be?

What I’ve already tried:

  1. Install the guzzle library;
  2. Switch TLS encryption to SSL;
  3. Check the server connection.

They all didn’t work out.

I appreciate the answers.

3 answers

-1

You can send the email if it is the same as . env

for ex:

 public function toMail($notifiable)
  {

    return (new MailMessage)->from('[email protected]', 'Ola!')
           ...
  }
MAIL_DRIVER=smtp
MAIL_HOST=smtp.hostinger.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=suasenha
MAIL_ENCRYPTION=

remember to leave MAIL_ENCRYPTION blank.

-1

I have already picked up a lot to configure this type of connection and reached the following conclusion.

Create and use Google accounts for sending email, which is why some email servers do not accept this type of sending.

Remembering that if you use a Gmail email you have to release to use less secure applications

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

-2

Define in your .env MAIL_FROM_ADDRESS and MAIL_FROM_NAME and the problem will be solved.

Browser other questions tagged

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