> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/document-processing/import/test-email-import-and-handling-tests.md).

# 测试：电子邮件导入和处理测试

## 目的

这些测试确保我们的系统能够正确处理电子邮件导入。这包括发送电子邮件、接收电子邮件并将其移至指定文件夹、检查邮件是否已读或未读、将邮件导入系统，以及随后执行清理。

## 测试步骤

1. **设置：**
   * **获取环境设置：** 从环境变量中加载电子邮件服务器信息和凭据等必要信息。
   * **加密电子邮件密码：** 安全加密电子邮件密码，以便安全使用。
2. **电子邮件发送和管理：**
   * **发送电子邮件：** 使用 SMTP 函数发送带有特定主题和附件的电子邮件。
   * **移动电子邮件：** 使用 IMAP 函数将电子邮件移至目标文件夹。
   * **列出文件夹：** 确认目标文件夹存在。
   * **删除电子邮件：** 从文件夹中删除电子邮件以完成清理。
   * **检查电子邮件状态：** 验证电子邮件是否标记为已读或未读。
3. **测试序列**

   **初始设置：**

   * **检查连接：** 验证与电子邮件服务器的连接，并获取连接 ID。
   * **登录测试：** 确认使用已存储的凭据能够成功登录。
   * **文件夹检查：** 确认目标文件夹存在于电子邮件服务器上。

   **电子邮件操作：**

   * **发送测试电子邮件：** 发送一封带有特定主题的电子邮件。
   * **获取电子邮件 ID：** 从收件箱中获取已发送电子邮件的 ID。
   * **移动电子邮件：** 将电子邮件从收件箱移至目标文件夹。
   * **检查电子邮件状态：** 确认目标文件夹中的电子邮件标记为未读。

   **电子邮件导入：**

   * **获取电子邮件：** 将目标文件夹中的电子邮件导入我们的系统。
   * **检查已导入的电子邮件：** 确认已正确获取并记录导入的电子邮件。

   **日志验证：**

   * **检查导入日志：** 验证已发送电子邮件的主题已记录在导入日志中。

   **清理：**

   * **删除已导入的文档：** 删除从电子邮件导入的文档。
   * **删除电子邮件：** 从文件夹中删除已发送并移动的电子邮件，保持环境整洁。

## 各项测试的详细说明

* **设置和初始化：**
  * **初始化共享数据：** 为测试准备共享数据。
* **电子邮件连接测试：**
  * **获取连接 ID：** 检查是否能够连接到电子邮件服务器，并获取连接 ID。
  * **登录验证：** 确保能够正常登录电子邮件服务器。
* **文件夹验证测试：**
  * **检查目标文件夹：** 确认目标文件夹存在于电子邮件服务器上。
  * **验证文件夹列表：** 确保服务器返回的文件夹列表与预期一致。
* **电子邮件发送和 ID 获取：**
  * **发送电子邮件：** 发送一封带有特定主题和附件的测试电子邮件。
  * **获取电子邮件 ID：** 从收件箱中获取这封已发送电子邮件的唯一 ID。
* **电子邮件移动和状态检查：**
  * **将电子邮件移至文件夹：** 将测试电子邮件从收件箱移至目标文件夹。
  * **检查未读状态：** 确认移动后电子邮件标记为未读。
* **电子邮件获取和响应验证：**
  * **从文件夹获取电子邮件：** 将目标文件夹中的电子邮件导入我们的系统。
  * **验证已获取的电子邮件：** 确认响应中包含已获取的电子邮件。
* **导入日志验证：**
  * **获取导入日志：** 获取已导入电子邮件的日志。
  * **检查日志中的电子邮件主题：** 确认导入日志中包含测试电子邮件的主题。
* **清理：**
  * **删除已导入的文档：** 删除从电子邮件导入的文档。
  * **删除电子邮件：** 从收件箱和目标文件夹中删除测试电子邮件，保持环境整洁。

\\


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/document-processing/import/test-email-import-and-handling-tests.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
