IBM Cloud Docs
使用Event NotificationsSMTP 接口

使用Event NotificationsSMTP 接口

IBM Cloud Event Notifications支持 SMTP,这是互联网上最常见的电子邮件协议。 通过连接到 IBM Cloud Event Notifications SMTP 接口,您可以使用各种支持 SMTP 的客户端、软件或编程语言发送电子邮件。 本文档介绍如何设置 SMTP 配置、获取用户凭证和设置 CBR 规则以访问 SMTP 服务器。

域名验证

在 IBM Cloud Event Notifications实例中创建 SMTP 配置后,您需要执行三种类型的验证,以获得通过 SMTP 接口发送电子邮件所需的参数。 这些验证位于“验证”选项卡下,可通过单击 菜单进行访问。

  1. 创建发件人策略框架(SPF),用于验证电子邮件的发件人。 SPF 指定允许针对您的域发送电子邮件的邮件服务器。

    • 确保域名已作为 A 记录存在于 DNS 记录中。
    • 针对配置的域名打开 DNS 托管提供程序
    • 使用配置屏幕中为 SPF 提供的名称和值,使用域名 registerer 创建新的 TXT 记录
  2. 创建 DomainKeys Identified Mail (DKIM),它允许一个组织通过签署邮件来承担传输邮件的责任。 DKIM 允许接收方检查声称来自特定域的电子邮件是否得到该域所有者的授权。

    • 针对配置的域名打开 DNS 托管提供程序
    • 使用 DKIM 的配置屏幕中提供的名称和值,使用域名 registerer 创建新的 TXT 记录
  3. 为了增强安全性,我们使用以下问卷对 SMTP 接口需求进行手动验证:

    1. Will the nature of the email content be Marketing or Transactional?
    
    2. What is your website's URL?
    
    3. Explain how you plan to use IBM Cloud Event Notifications to send email. To help us process your request, you should answer the following questions:
    
    a. What is your strategy for creating or obtaining your email subscriber list?
    
    b. What is your approach to managing bounced emails and handling recipient complaints?
    
    c. What methods do you have in place for recipients to unsubscribe from your email communications?
    
    d. How did you determine the sending rate or quota specified in your request?
    
    e. Are you regularly cleaning your email list to remove invalid or outdated email addresses?
    
    4. Indicate the email addresses where you wish to receive account-related communications. You can provide a list of up to four email addresses, separated by commas.
    
    5. In the Event Notifications subscription, you are asked to provide a Reply-To field. Confirm that this is a valid email-id with a mailbox.
    
    6. Include a statement affirming your commitment to sending emails only to individuals who have explicitly requested them, and verify that you have established a procedure for managing bounce and complaint notifications.
    
    7. Whether you have a manual or automated process in place for handling unsubscribes, it's important to provide an "unsubscribe" link in the email payload you send. When recipients decide not to receive further emails, they can simply click on the 'unsubscribe' link and remove their email address from your mailing list. Add a statement that you agree to have an “unsubscribe” link in the email payload that you send.
    
    8. If you send the html content in the notification payload, do you have a process to validate this content is well formatted? Ill formatted HTML content may descrese the server reputation.
    

    虽然许多问题都是不言而喻的,但我们为几个问题提供了解释,以确保清晰度。

    • 提供电子邮件的性质: 市场营销或交易。

      • 市场营销电子邮件: 这些电子邮件分发给广泛的受众,针对的是具有市场营销和促销内容的潜在客户或客户列表,例如鼓励购买或下载信息。
      • 交易电子邮件: 这些电子邮件针对每个收件人进行个性化处理,通常由特定用户操作 (例如,进行 Web 站点购买或请求密码重置) 触发。
    • 需要提供网站 URL,以便更清楚地了解您打算发送的内容类型。

    • 需要有效的“回复电子邮件标识”才能接收有关已拒绝或退回的电子邮件的信息。

    • 需要格式正确的电子邮件内容,以防止在收件人端将电子邮件归类为垃圾邮件。 格式不正确 (例如,不在 HTML 中) 的电子邮件可能会导致电子邮件服务提供者将电子邮件分类为垃圾邮件。

    在填写上述问题的答案后,用户必须通过支持凭单请求启用 SMTP 接口 Event Notifications 验证:

    1. 从 IBM Cloud 控制台菜单栏中,单击 帮助 图标> 支持中心
    2. 在“联系人支持”部分中,单击 创建案例
    3. Category 下选择 Topic 作为 Event Notifications,在 Subtopic 作为其他
    4. Subject add 下,请求授权为 Event Notifications启用 SMTP 接口
    5. 在“说明”部分,首先提供 IBM Cloud Event Notifications instance id、创建实例的 region 和格式为 {{uuid}}._domainkey.{{domain}}DKIM Name
    6. 稍后,请包括对上述调查表的答复。
    7. 如果要提供更多支持答案的证据,请添加 附件
    8. 关注列表 部分中添加必需的电子邮件标识。 要在创建支持案例时了解更多有关其他选项的信息,请参阅 此处

一些共同的核查问题可以是:

  1. 确保域名拼写正确。
  2. 验证是否正确更新了域的 DNS 记录,包括 SPF/DKIM 值。
  3. DNS 传播可能需要 72 小时才能在互联网上更新。

值得注意的是,我们对提供的域的 SPF 和 DKIM TXT 记录进行定期检查。 为了确保不间断的电子邮件传递,我们建议即使在验证一次记录之后,也保持将这些记录插入 DNS 中。 如果 SPF 或 DKIM 在定期检查中失败,我们将暂停电子邮件发送。

启用基于上下文的访问 SMTP 接口限制

传统的基于 IP 的 SMTP 接口允许列表现已过时。 在连接 SMTP 接口时,必须迁移到基于上下文的限制。 当前允许列表中的 IP 将在未来六个月内继续使用,以便有时间进行过渡。

默认情况下,SMTP 接口的访问受任何 IP 地址的限制。 要允许访问 SMTP 接口,必须启用 基于上下文的限制。 要访问 SMTP 界面,必须在设置 CBR 规则时将 API 类型选择为 SMTP 配置

在设置 CBR 规则时所选择的网络区域中的所有相关 IP 都会被自动列入允许连接 SMTP 服务器的名单。

必须为打算用于 SMTP 接口功能的 IBM Cloud Event Notifications实例设置 CBR 规则

通过 SMTP 接口发送电子邮件的需求

在 IBM Cloud Event Notifications实例中成功验证 SMTP 配置后,要使用 SMTP 接口发送电子邮件,您需要以下参数:

  1. 下表列出了每个地区的 IBM Cloud Event Notifications SMTP 端点列表:

    IBM Cloud Event NotificationsSMTP 端点
    Event Notifications 实例区域 SMTP 公共端点 SMTP 专用端点
    us-south (Dallas) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    卡托尔(多伦多) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    jp-tok (东京) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    jp-osa (大阪) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    au-syd (悉尼) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    欧格布 (伦敦) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com
    欧德 (法兰克福) smtp.eu-de.event-notifications.cloud.ibm.com private.smtp.eu-de.event-notifications.cloud.ibm.com
    欧-斯 (马德里) smtp.eu-de.event-notifications.cloud.ibm.com private.smtp.eu-de.event-notifications.cloud.ibm.com
    br-sao (圣保罗) smtp.us-south.event-notifications.cloud.ibm.com private.smtp.us-south.event-notifications.cloud.ibm.com

    SMTP 端点在以下地区可用:us-southeu-de. 例如,可以看到在伦敦和悉尼创建的实例也连接到达拉斯 SMTP 端点,在马德里创建的实例也连接到法兰克福 SMTP 端点。

  2. SMTP 接口端口号。 当前支持的端口 587。

  3. SMTP 用户名和密码。 用户名和密码在所有 SMTP 配置中都是唯一的,密码使用单向散列加密。 最多可以在单个 SMTP 配置中创建 5 个用户。 我们当前支持来自 SMTP 协议的 LoginPlain 认证方法。

  4. IBM Cloud Event Notifications SMTP 接口目前支持通过 StartTLS 方法进行连接,以便在网络上安全传输数据。

  5. 客户机软件或程序可以严格使用传输层安全性 (TLS) 进行通信。

  6. 可以提供有效的 IP 地址或子网,客户机将从这些 IP 地址或子网连接到 SMTP 接口。

  7. 当通过 SMTP 接口访问 IBM Cloud Event Notifications时,您的 SMTP 客户端应用程序会组装信息。 您需要提供的信息可能因您使用的应用程序而异。 以下是客户机与服务器之间的 SMTP 交换的最低要求:

    • 源地址:源地址必须属于已配置的域;否则,发件人地址将被拒绝。
    • 目标地址: 目标地址可以是任何有效的电子邮件地址或一组电子邮件地址
    • 消息数据: 确保消息数据无垃圾,干净且明智。
  8. 下面提到了基于 SMTP 端点的传出 IP 地址列表。 这些 IP 将在收件人的电子邮件客户端上列出:

    IBM Cloud Event Notifications发送的 IP 地址
    SMTP 端点 传出 IP 地址
    smtp.us-south.event-notifications.cloud.ibm.com 150.240.68.207, 52.118.103.220, 169.47.95.114, 169.59.33.169, 150.239.167.120, 52.118.185.176
    smtp.eu-de.event-notifications.cloud.ibm.com 149.81.218.203, 158.177.6.24, 149.81.39.14, 158.176.12.194, 149.81.164.10, 161.156.160.31
  9. 根据当前配置,在 Event Notifications SMTP 界面中不支持附件。

使用 SMTP 接口发送电子邮件

  1. 使用提供的 SMTP 端点、端口和有效的用户名-密码凭证,配置支持 SMTP 的软件,包括 ServiceNow, Jira、博客平台、RSS 聚合器、列表管理软件和工作流系统。

  2. 要使用 SMTP 接口发送电子邮件,可以使用支持 SMTP 的编程语言,电子邮件服务器或应用程序。 确保完成上述所有必要步骤,并拥有正确的 SMTP 端点、端口和凭据以连接到 IBM Cloud Event Notifications SMTP 接口。

  3. 如果您当前管理自己的电子邮件服务器,那么可以使用 IBM Cloud SMTP 端点,端口和凭证通过 Event Notifications SMTP 配置发送所有外发电子邮件,而无需修改现有电子邮件客户端和应用程序。

  4. 要使用命令行与 IBM Cloud Event Notifications SMTP 接口交互,请按照下面的示例操作:

    openssl s_client -starttls smtp -connect {{smtp_endpoint}}:587
    ...
    ...
    ...
    auth login
    334 VXNlcm5hbWU6
    dXNlcm5hbWU=
    334 UGFzc3dvcmQ6
    cGFzc3dvcmQ=
    235 2.7.0 Authentication successful
    mail from: mailer@example.com
    250 2.1.0 Ok
    rcpt to: recipient@test.com
    250 2.1.5 Ok
    data
    354 End data with <CR><LF>.<CR><LF>
    from: Mailer <mailer@example.com>
    to: Recipient <recipent@test.com>
    Subject: IBM Cloud Event Notifications SMTP interface
    Get the all events securely from IBM EN SMTP Interface
    .
    

使用 SMTP 专用端点发送电子邮件

  1. 要通过 SMTP 专用端点发送电子邮件,您需要在 IBM Cloud Virtual Private Cloud (VPC) 中创建或附加虚拟专用端点 (VPE)。

  2. 确保将 VPE 网关连接到部署 IKS(IBM Kubernetes Service)群集或 VSI(虚拟服务实例)的同一 VPC。

  3. 创建 VPE 时:

    1. 选择所需的区域和 VPC,从这里连接到 SMTP 专用端点。
    2. 在“请求连接到服务”下,选择"Event Notifications"。
    3. 启用端点:private.smtp.<region>.event-notifications.cloud.ibm.com
    4. 为保留 IP 选择所需的子网(注意:每个 VPC 区域只能将一个 IP 地址绑定到端点网关)。

    SMTP 专用端点
    专用端点

  4. Context-Based-Restrictions(CBR) 中为您的 VPC 创建 Network Zone

  5. Event-Notifications 实例创建 CBR 规则,并添加上述已创建的 Network zone (或者)将上述 Network Zone 添加到已为 Event-Notifications 实例创建的 CBR 规则

  6. 请尝试使用 此处 列出的相应 SMTP 专用端点。

跟踪电子邮件状态

  • 从上述任何方法发送电子邮件后,您将收到一个队列标识,这将有利于调试目的。
  • 此功能允许用户监视通过定制电子邮件目标发送的电子邮件的交付状态,以确保透明度并增强整体用户体验。 有关更多信息,请遵循 这些步骤