I'm trying to send mail with SendGrid, picking up the email that the user wants to send and the message, but I'm having this error when i try to submit:

Failed to authenticate on SMTP server with username "João Gabriel" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 250 but got an empty response in ...

My Mailable:

public $remetente;
public $nome;
public $destinatario;
public $data;

public function __construct($remetente, $nome, $destinatario, $data)
{
    $this->remetente = $remetente;
    $this->nome = $nome;
    $this->destinatario = $destinatario;
    $this->data = $data;

}

public function build()
{
    //$address = '[email protected]';
    $subject = 'This is a demo!';
    $name = 'Jane Doe';
    return $this->view('emails.test')
                ->from($this->remetente, $this->nome)
                ->subject($subject)
                ->replyTo($this->destinatario, $name);
}

}

My Controller:

public function enviarEmail(Request $request){
    $destinatario = $request->input('destinatario');
    $mensagem = $request->input('mensagem');
    $remetente = \Auth::user()->email;
    $nome = \Auth::user()->name;

    Mail::to($destinatario)->send(new TestEmail($remetente, $nome, $destinatario, $mensagem));
}

Can someone help me?

1 Answers

0
Fjarlaegur On Best Solutions

Your error message indicates that there is something wrong with the authentication on the SMTP server. There seems to be nothing wrong with your code.

Maybe inspect the error message better, there might be a specific log message somewhere down the stacktrace maybe?

Have you verified your credentials to be correct? Have you verified host and port? Check your .env file and the config/mail.php to see if your settings are correct.