ruby-on-rails - 如何使用凭据在 Rails 6 中实现 Sendgrid
问题描述
我在将 Sendgrid 与 Rails 6 集成时遇到了困难,我现在有点迷茫,因为根据我的终端,电子邮件正在发送到相应的电子邮件地址。
OrderMailer#receipt: processed outbound mail in 17.9ms
Delivered mail 5f0b2c075e025_c1014870205f@aarons-macbook-pro.home.mail (8.1ms)
Date: Sun, 12 Jul 2020 17:28:07 +0200
From: john@anotherpin.com
To: *******@gmail.com
Message-ID: <5f0b2c075e025_c1014870205f@aarons-macbook-pro.home.mail>
Subject: Thank you for ordering from AnotherPin!
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5f0b2c075ceb9_c10148702043a";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5f0b2c075ceb9_c10148702043a
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Thank you for your order!
-------------------------
Order ID: 148
Name: John Doe
Total price: $18.00
Thanks for your support!
----==_mimepart_5f0b2c075ceb9_c10148702043a
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
但是,当我检查测试电子邮件收件箱时,从未收到邮件,即使检查垃圾邮件文件夹也是如此。
我很困惑,因为我在 Rails 控制台中没有收到任何错误消息。
这是我在 development.rb 中包含的内容:
config.action_mailer.smtp_settings = {
address: 'smtp.sendgrid.net',
port: 587,
domain: 'john@anotherpin.com',
user_name: 'apikey',
password: Rails.application.credentials[Rails.env.to_sym][:sendgrid_username],
authentication: 'plain',
enable_starttls_auto: true }
我知道,截至 2020 年 4 月,Sendgrid 需要验证发件人才能使用他们的任何服务,所以我已经成功地继续这样做了。尽管如此,我的消息似乎没有发送到测试电子邮件收件箱。
有谁知道为什么我看到它们是在我的终端中发送的,而不是在我的实际收件箱中。
解决方案
推荐阅读
- c# - 在 Excel 中导出网格的逻辑
- javascript - 如何更改特定网格框的背景颜色?
- python - 使用 Pandas python 复制文件并上传到另一个 csv 文件
- oracle - REGEXP_SUBSTR 匹配后删除所有字符
- python - 为什么 pandas 将 UNIX 时间戳转换为多个不同的日期时间值?
- amazon-web-services - 使用 NATGW 创建 VPC/IGW、VPN 和私有子网的 Terraform 项目 - 连接分析器说没有从 NATGW 到 IGW 的路由
- google-sheets - 如何使用 vlookup 或索引/匹配来返回公式而不是值?
- mysql - 转换表以获取所需的数据
- swift - 为什么 IndexSet 说插入了一个新元素,即使该元素已经在集合中?
- django - 部署postgres nginx后的Django问题连接