跳转到内容

Mail测试任务

Mail测试任务 定义一个 Mail(POP3/IMAP) 协议测试任务,用于 Mail 功能、性能、稳定性和自定义测试。

主参数清单

参数类型必填长度限制说明
targetenum-任务类型
固定值:MAIL
namestring≤400 字符任务名称
唯一标识邮件任务
descriptionstring≤800 字符任务描述
详细说明任务目的
enabledboolean-启用状态
true:启用(默认)
false:禁用
beforeNamestring≤400 字符前序任务
控制任务执行顺序
protocolenum-邮件协议
POP3:邮局协议
IMAP:互联网消息访问协议
serverobject-服务器配置
详见下方服务器配置说明
mailobject-邮件配置
详见下方邮件配置说明

注意

支持同时编排多个 Mail 接口,但每次只允许启用一个 Mail 进行测试。

Mail完整结构配置示例:

yaml
- target: MAIL
  name: Get mail messages (IMAP)
  description: Using IMAP protocol to obtain emails
  enabled: true
  protocol: IMAP
  server:
    # 邮件服务器配置 ...
  mail:
    # 邮件配置

Mail服务器配置(server)

字段名称类型必填范围/长度默认值说明
serverstring--邮件服务器地址
支持域名/IP
示例:mail.example.com
portinteger1-65535-服务端口
标准端口:
SMTP:25, POP3:110, IMAP:143
加密端口:
SMTPS:465, POP3S:995, IMAPS:993
securityobject--安全配置对象
详见安全配置说明
useAuthboolean-true启用认证
true:需要用户名密码
false:匿名访问
usernamestring条件≤400 字符-认证账号
useAuth=true时必填
完整邮箱格式:user@domain.com
passwordstring条件≤4096 字符-认证凭证
useAuth=true时必填
支持加密存储
connectTimeoutstring1s-24h6s连接超时
格式:数字+单位(如10s
建立 TCP 连接最大等待时间
readTimeoutstring1s-24h60s读取超时
格式:数字+单位(如30s
单次数据读取最大等待时间

Mail服务器结构配置示例:

yaml
server:
  server: 192.168.0.211
  port: 993
  security:
    # 安全配置 ...
  useAuth: true
  username: test001@xcan.cloud
  password: test001@xcan
  readTimeout: 60s
  connectTimeout: 6s

Mail服务器安全配置(security)

参数类型必填长度限制默认值说明
useenum-NONE加密类型
NONE:明文传输
USE_SSL:SSL 加密
USE_STARTTLS:STARTTLS 升级
trustAllCertsboolean-false信任所有证书
true:跳过证书验证(危险)
false:验证证书有效性
enforceStartTLSboolean-false强制 STARTTLS
true:拒绝不支持的服务器
false:降级为明文
useLocalTrustStoreboolean-false使用本地信任库
true:使用自定义证书
false:使用系统默认
trustStorePathstring条件≤4096 字符-信任库路径
本地证书文件路径
示例:/etc/ssl/custom.pem
trustStoreBase64Contentstring条件≤40KB-信任库内容
Base64 编码证书内容
tlsProtocolsstring≤80 字符-强制协议版本
示例:TLSv1.2, TLSv1.3

注意

使用 trustStorePath 时需要确保文件已上传到对应执行节点路径。

Mail服务器安全配置示例:

yaml
security:
  use: USE_START_TLS
  trustAllCerts: true
  enforceStartTLS: false
  useLocalTrustStore: false
  trustStorePath: ""
  trustStoreBase64Content: VGhpcyBpcyBhIGNlcnRpZmljYXRlIGNvbnRlbnQ=
  tlsProtocols: TLSv1.2

Mail邮件配置(mail)

字段名称类型是否必须长度/数量限制描述
folderstring≤100 字符目标邮件夹
默认值:INBOX
支持标准邮件夹(SENT/DRAFTS/TRASH)或自定义路径
deleteMessageboolean-邮件删除策略
true:处理完成后自动删除邮件
false:保留邮件(默认)
storeMimeMessageboolean-原始邮件存储
true:以 MIME 格式保存完整邮件到任务目录
false:不存储(默认)
numMessagesinteger≥0邮件处理数量
默认值:1
0:处理所有邮件
N:限制处理 N 封邮件

Mail邮件配置示例:

yaml
mail:
  folder: INBOX
  deleteMessage: false
  storeMimeMessage: true
  numMessages: 1

脚本示例(target)

完整参数配置示例

yaml
- target: MAIL
  name: Get mail messages (IMAP)
  description: Using IMAP protocol to obtain emails
  enabled: true
  protocol: IMAP
  server:
    server: 192.168.0.211
    port: 993
    security:
      use: USE_START_TLS
      trustAllCerts: true
      enforceStartTLS: false
      useLocalTrustStore: false
      trustStorePath: ""
      trustStoreBase64Content: VGhpcyBpcyBhIGNlcnRpZmljYXRlIGNvbnRlbnQ=
      tlsProtocols: TLSv1.2
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    folder: INBOX
    deleteMessage: false
    storeMimeMessage: false
    numMessages: 1

使用IMAP协议获取电子邮件

yaml
- target: MAIL
  name: Get mail messages (IMAP)
  description: Using IMAP protocol to obtain emails
  enabled: true
  protocol: POP3
  server:
    server: 192.168.0.211
    port: 995
    security:
      use: USE_START_TLS
      trustAllCerts: true
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    folder: INBOX
    deleteMessage: false
    storeMimeMessage: false
    numMessages: 1

使用POP3协议获取电子邮件

yaml
- target: MAIL
  name: Get mail messages (POP3)
  description: Using POP3 protocol to obtain emails
  enabled: true
  protocol: POP3
  server:
    server: 192.168.0.211
    port: 995
    security:
      use: USE_START_TLS
      trustAllCerts: true
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    folder: INBOX
    deleteMessage: false
    storeMimeMessage: false
    numMessages: 1

基于 GPL-3.0 许可发布