【问题标题】:Troueble to sending email in laravel在 laravel 中发送电子邮件的问题
【发布时间】:2019-05-28 19:24:52
【问题描述】:

我正在尝试使用 SendGrid 发送邮件,获取用户想要发送的电子邮件和消息,但是当我尝试提交时出现此错误:

未能使用 2 个可能的身份验证器在用户名“João Gabriel”的 SMTP 服务器上进行身份验证。 Authenticator LOGIN 返回 Swift_TransportException: Expected response code 250 but got a empty response in ...

我的可邮寄:

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 = 'janeexampexample@example.com';
    $subject = 'This is a demo!';
    $name = 'Jane Doe';
    return $this->view('emails.test')
                ->from($this->remetente, $this->nome)
                ->subject($subject)
                ->replyTo($this->destinatario, $name);
}

}

我的控制者:

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));
}

有人可以帮我吗?

【问题讨论】:

    标签: laravel-5


    【解决方案1】:

    您的错误消息表明 SMTP 服务器上的身份验证存在问题。您的代码似乎没有任何问题。

    也许更好地检查错误消息,也许在堆栈跟踪的某个地方有特定的日志消息?

    您是否已验证您的凭据是否正确?您是否验证了主机和端口?检查您的.env 文件和config/mail.php 以查看您的设置是否正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-21
      • 2021-08-28
      • 1970-01-01
      • 2015-11-27
      • 2012-01-02
      • 1970-01-01
      • 2015-10-16
      相关资源
      最近更新 更多