微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

既然 Heroku SendGrid 集成需要双重身份验证,我该如何升级它们?

如何解决既然 Heroku SendGrid 集成需要双重身份验证,我该如何升级它们?

我对 SendGrid 的新变化感到非常困惑。我需要改变什么?

我收到了一封电子邮件

We are emailing to inform you that Twilio SendGrid Now requires you to authenticate with API Keys,and we require Two-Factor Authentication (2FA) to login to your account as of February 17th,2021.This requirement is in order to ensure uninterrupted service and improve the security of your account. Our records show that one or more users on your account used basic authentication with username and password for one or more of your SendGrid API requests or SMTP configuration within the last 4 months. If you did not take action,your API and SMTP requests will be rejected starting February 17th,2021.

我认为我的设置没有使用 API 密钥,尽管我的环境变量中有一个

  config.action_mailer.smtp_settings = {
    :address        => 'smtp.sendgrid.net',:port           => '587',:authentication => :plain,:user_name      => ENV['SENDGRID_USERNAME'],:password       => ENV['SENDGRID_PASSWORD'],:domain         => 'heroku.com',:enable_starttls_auto => true
  }

我的 SendGrid 帐户显示在 17 日左右发送的邮件明显减少,如电子邮件中所述,但仍有一些活动,令人困惑:

enter image description here

我正在使用 sendgrid-ruby (5.3.0) 红宝石

new documentation on SendGrid 似乎说将 api 密钥作为用户名和密码发送:

ActionMailer::Base.smtp_settings = {
  :user_name => 'apikey',:password => 'your_sendgrid_api_key',:domain => 'yourdomain.com',:address => 'smtp.sendgrid.net',:port => 587,:enable_starttls_auto => true
}

但是什么是 apikey,它与 your_sendgrid_api_key 有何不同?

解决方法

这里是 Twilio 开发者布道者。

当您使用 SMTP 通过 SendGrid 发送电子邮件时,您需要对自己进行身份验证。 SMTP 使用需要用户名和密码的基本身份验证。为了使用 API 密钥作为密码,我们还需要一个用户名。

由于 API 密钥是您实际验证自己的全部内容,因此用户名是一种占位符。因此,在示例中,用户名是“apikey”,但实际上它应该设置为:“apikey”。

然后应将密码设置为您的 API 密钥,您create in the SendGrid admin console。所以代码应该是这样的:

username = "apikey"
password = ENV["SENDGRID_API_KEY"]

ActionMailer::Base.smtp_settings = {
  :user_name => username,:password => password,:domain => 'yourdomain.com',:address => 'smtp.sendgrid.net',:port => 587,:authentication => :plain,:enable_starttls_auto => true
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。