laravel - Sendgrid 不在服务器上发送邮件
问题描述
我第一次使用 Sendgrid,并将它与我的 Laravel 7 项目集成。我在 sendgrid 上注册并生成了 API KEY 并成功配置了.env
文件。
现在我可以在本地主机上发送和接收邮件,但是当我在服务器上使用相同的配置时,它给了我以下错误
stream_socket_enable_crypto(): Peer certificate CN=`ip-107-180-95-117.ip.secureserver.net' did not match expected CN=`smtp.sendgrid.net
我试图用谷歌搜索解决方案并遇到了这两个解决方案
1)用空字符串替换tls:我tls
从.env
文件中删除并用文件tls
中的空字符串替换mail.php
2)在mail.php中添加以下代码
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
],
这两种解决方案都导致我出现另一个错误
Failed to authenticate on SMTP server with username "apikey" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data
↵". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data
我的 Godaddy 服务器可能有什么问题,因为 sendgrid 正在本地主机上工作
解决方案
推荐阅读
- react-native - Appending two audiofiles React Native
- python - 如何使用 GraphQL 发送持久数据结构及其随时间的变化?
- ruby-on-rails - 在导入 CSV Rails 时验证唯一性而不中止更新过程
- json - 通过 NIFI 将带有 jsonb 列的记录插入 Postgres
- json - 将 OpenApi 路径拆分为多个路径定义文件
- sql - SQL - 结果来自工作日(时间)和来自星期(无时间)
- html - 为什么我的 CSS 不工作,尽管不透明度工作?
- html - 导航栏未正确堆叠
- php - PHP 偶尔且无意地将对象返回为 null
- animation - 如何像在 SwiftUI 中打开 App 一样转换到新视图?