I can not get my email to be accepted when sending emails

0

You see, I'm trying to send email messages to users. To do that, I must configure the .env file:

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

After that, I create the function that will send the message to a certain user:

public function mensajeActivar(User $usuario){
        Mail::to($usuario->email)->send(new Mensajeria($usuario->id));

        return back()->with('message',['success',"Se ha enviado al usuario un mensaje que redirige al código de activación"]);
    }

The file Mensajeria.php:

<?php

namespace App\Mail;

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

class Mensajeria extends Mailable{
    use Queueable, SerializesModels;
    public $numero;

    public function __construct($numero){
        $this->numero=$numero;
    }

    public function build(){
        return $this->view('activacion');
    }
}

The activacion.blade.php file:

<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
    <title>Active su cuenta en Bolsa Empleo</title>
</head> 
<body>
    <p>Se ha registrado con exito.</p><br>
    <p>Pulse el siguiente enlace para activar su cuenta:</p><br>
    <a href='http://localhost/bolsa/public/activar/{{$numero}}'>Activar</a>
</body>
</html>

But after this, I run into this error message:

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 v66sm16186852wmd.41 - gsmtp "

I'm supposed to have my account enabled for use with unsecured programs, but I'm not sure what I'm supposed to do.

    
asked by Miguel Alparez 01.05.2018 в 18:00
source

0 answers