【问题标题】:Laravel Sendgrid SMTP not workingLaravel Sendgrid SMTP 不工作
【发布时间】:2018-01-06 18:28:03
【问题描述】:

我正在尝试使用 Sendgrid SMTP 发送常规 Mail:: 电子邮件。但他们没有通过,在我的 Sendgrid 仪表板上看不到任何已发送的电子邮件,但也没有收到任何错误。

它确实有效,如果我将其更改为 Gmail SMTP 信息,它仍然有效。

关于我可以看什么的任何建议?

邮件.php

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

'host' => env('MAIL_HOST', 'ssl://smtp.sendgrid.net'),

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

'from' => ['address' => null, 'name' => null],

'encryption' => env('MAIL_ENCRYPTION', ''),

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

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

.env

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=sendgrid_username
MAIL_PASSWORD=sendgrid_password
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="name"
MAIL_FROM_ADDRESS=no-reply@email.com

【问题讨论】:

  • 远射 - 从 MAIL_FROM_NAME 中删除双引号。文档说只有在值中有空格时才需要它。
  • 我删除了这篇文章的名称,它在实际的实时设置中确实有一个空格。

标签: php laravel sendgrid


【解决方案1】:

确保您:

将您的用户名设置为字符串apikey。将您的密码设置为实际的 API 密钥 生成。

根据documentation

【讨论】:

    【解决方案2】:

    来自官方文档:https://sendgrid.com/docs/for-developers/sending-email/laravel/

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.sendgrid.net
    MAIL_PORT=587
    MAIL_USERNAME=sendgrid_username
    MAIL_PASSWORD=sendgrid_password
    MAIL_ENCRYPTION=tls
    MAIL_FROM_NAME="John Smith"
    MAIL_FROM_ADDRESS=from@example.com
    

    【讨论】:

      【解决方案3】:

      使用用户名作为所有 API 的 API 密钥。

      MAIL_USERNAME=apikey

      【讨论】:

        【解决方案4】:

        我意识到这是一个老问题,但对于那些在谷歌上搜索的人来说,设置 MAIL_DRIVER=smtp 应该可以工作。

        【讨论】:

          【解决方案5】:

          MAIL_USERNAME 是您的用户名 MAIL_PASSWORD 是您的密码,MAIL_DRIVER=smtp、MAIL_HOST=smtp.sendgrid.net 和 MAIL_PORT=587。 如果您想使用 sendgrid 发送事务性电子邮件,请使用此示例 https://usingphp.com/post/send-transactional-email-with-sendgrid-in-laravel

          【讨论】:

            猜你喜欢
            • 2021-05-20
            • 2019-06-18
            • 2012-09-02
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-05-21
            • 2016-08-14
            相关资源
            最近更新 更多