跳转到内容

Smtp测试任务

Smtp测试任务 定义一个 Smtp 协议测试任务,用于 Smtp 功能、性能、稳定性和自定义测试。

主参数清单

字段名称类型必填长度/范围默认值描述
targetenum-SMTP任务类型标识
固定值:SMTP
namestring≤400 字符-任务唯一标识
示例:订单通知邮件
descriptionstring≤800 字符-任务描述
详细说明邮件用途
enabledboolean-true启用状态
true:执行任务
false:跳过任务
beforeNamestring≤400 字符-前序任务
控制执行顺序
示例:数据准备任务
serverobject--SMTP 服务器配置
包含连接和认证信息
mailobject--邮件内容配置
包含发件人、收件人、主题、正文等

注意

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

Mail完整结构配置示例:

yaml
- target: SMTP
  name: Send mail messages (SMTP)
  description: Using SMTP protocol to send emails
  enabled: true
  server:
    # 邮件服务器配置 ...
  mail:
    # 邮件配置

Smtp服务器配置(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
单次数据读取最大等待时间

Smtp服务器结构配置示例:

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

Smtp服务器安全配置(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 时需要确保文件已上传到对应执行节点路径。

Smtp服务器安全配置示例:

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

Smtp邮件发送配置(mail)

字段名称类型必填长度限制描述
mailFromstring≤4096 字符发件人地址
格式:"显示名 <email@domain.com>"
未设置时使用服务器认证账户
replyTostring≤4096 字符回复地址
多个地址用英文分号分隔
示例:"support@company.com;feedback@company.com"
receiverTostring≤4096 字符主送地址
多个地址用英文分号分隔
示例:"user1@example.com;user2@example.com"
receiverCCstring≤4096 字符抄送地址
多个地址用英文分号分隔
示例:"manager@example.com;team@example.com"
receiverBCCstring≤4096 字符密送地址
多个地址用英文分号分隔
示例:"archive@example.com;audit@example.com"
contentobject-邮件内容配置
包含主题、正文、附件等完整内容

参数分组与关系示意图:

Smtp邮件发送配置示例:

yaml
mail:
  mailFrom: test002@xcan.cloud
  replyTo: reply@xcan.cloud
  receiverTo: test001@xcan.cloud
  receiverCC: ccrecipient@xcan.cloud
  receiverBCC: bccrecipient@xcan.cloud
  content:
    subject: The subject of the email
    suppressSubject: false
    message: The main content or body of the email.
    plainBody: true
    includeTimestamp: true
    localAttachFiles:
      - /data/attach1.txt
      - /data/attach2.txt
    localAttachBase64Contents:
      attach1.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQxIGNvbnRlbnQ=
      attach2.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQyIGNvbnRlbnQ=
    messageSizeStatistics: true
    headerFields:
      X-MyHeader1: CustomValue1
      X-MyHeader2: CustomValue2
    sendEmlMessage: false
    localEmlMessageFile: /data/test.eml
    localEmlMessageBase64Content: VGhpcyBpcyBhIGVtYWlsIGNvbnRlbnQ=
    enableDebugLogging: true

Smtp发送邮件内容配置(content)

字段名称类型必填长度/数量限制描述
subjectstring≤4096 字符邮件主题
清晰描述邮件内容
示例:订单确认 - #{orderId}
suppressSubjectboolean-禁用主题
true:发送无主题邮件
false:包含主题(默认)
messagestring≤2MB邮件正文
支持纯文本/HTML 格式
使用plainBody指定格式
plainBodyboolean-纯文本格式
true:纯文本
false:HTML 格式(默认)
includeTimestampboolean-包含时间戳
true:在正文添加发送时间
false:不添加(默认)
localAttachFilesarray1-100 项本地附件路径
多个文件路径数组
示例:["/reports/invoice.pdf", "/data/export.csv"]
localAttachBase64Contentsmap1-100 项Base64 附件内容
键:文件名
值:Base64 编码内容
示例:{"report.xlsx": "base64string..."}
messageSizeStatisticsobject-邮件大小统计
包含邮件大小信息
示例:{enabled: true, maxSize: "10MB"}
headerFieldsmap1-200 项自定义邮件头
键值对形式
示例:X-Priority: "1"
X-Mailer: "AngusTester"
sendEmlMessageboolean-使用 EML 格式
true:发送 EML 格式邮件
false:标准格式(默认)
localEmlMessageFilestring≤4096 字符EML 文件路径
sendEmlMessage=true时使用
localEmlMessageBase64Content二选一
localEmlMessageBase64Contentstring≤2MBBase64 编码 EML 内容
sendEmlMessage=true时使用
localEmlMessageFile二选一
enableDebugLoggingboolean-启用调试日志
true:记录详细发送日志
false:仅错误日志(默认)

注意

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

  • Smtp发送邮件内容配置示例:*
yaml
content:
  subject: The subject of the email
  suppressSubject: false
  message: The main content or body of the email.
  plainBody: true
  includeTimestamp: true
  localAttachFiles:
    - /data/attach1.txt
    - /data/attach2.txt
  localAttachBase64Contents:
    attach1.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQxIGNvbnRlbnQ=
    attach2.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQyIGNvbnRlbnQ=
  messageSizeStatistics: true
  headerFields:
    X-MyHeader1: CustomValue1
    X-MyHeader2: CustomValue2
  sendEmlMessage: false
  localEmlMessageFile: /data/test.eml
  localEmlMessageBase64Content: VGhpcyBpcyBhIGVtYWlsIGNvbnRlbnQ=
  enableDebugLogging: true

脚本示例(target)

完整参数配置示例

yaml
- target: SMTP
  name: Send mail messages (SMTP)
  description: Using SMTP protocol to send emails
  enabled: true
  server:
    server: 192.168.0.211
    port: 465
    security:
      use: USE_START_TLS
      trustAllCerts: true
      enforceStartTLS: false
      useLocalTrustStore: false
      trustStoreBase64Content: VGhpcyBpcyBhIGNlcnRpZmljYXRlIGNvbnRlbnQ=
      tlsProtocols: TLSv1.2
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    mailFrom: test002@xcan.cloud
    replyTo: reply@xcan.cloud
    receiverTo: test001@xcan.cloud
    receiverCC: ccrecipient@xcan.cloud
    receiverBCC: bccrecipient@xcan.cloud
    content:
      subject: The subject of the email
      suppressSubject: false
      message: The main content or body of the email.
      plainBody: true
      includeTimestamp: true
      localAttachFiles:
        - /data/attach1.txt
        - /data/attach2.txt
      localAttachBase64Contents:
        attach1.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQxIGNvbnRlbnQ=
        attach2.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQyIGNvbnRlbnQ=
      messageSizeStatistics: true
      headerFields:
        X-MyHeader1: CustomValue1
        X-MyHeader2: CustomValue2
      sendEmlMessage: false
      localEmlMessageFile: /data/test.eml
      localEmlMessageBase64Content: VGhpcyBpcyBhIGVtYWlsIGNvbnRlbnQ=
      enableDebugLogging: true

发送纯文本电子邮件

yaml
- target: SMTP
  name: Send mail plain message (SMTP)
  description: Using SMTP protocol to send plain message email
  enabled: true
  server:
    server: 192.168.0.211
    port: 465
    security:
      use: USE_SSL
      trustAllCerts: true
      enforceStartTLS: false
      useLocalTrustStore: false
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    mailFrom: test002@xcan.cloud
    receiverTo: test001@xcan.cloud
    content:
      subject: The subject of the email
      suppressSubject: false
      message: The main content or body of the email.
      plainBody: true
      enableDebugLogging: false

发送包含附件的文本电子邮件

yaml
- target: SMTP
  name: Send mail local attachments message (SMTP)
  description: Using SMTP protocol to send local attachments message email
  enabled: true
  server:
    server: 192.168.0.211
    port: 465
    security:
      use: USE_SSL
      trustAllCerts: true
      enforceStartTLS: false
      useLocalTrustStore: false
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    mailFrom: test002@xcan.cloud
    receiverTo: test001@xcan.cloud
    content:
      subject: The subject of the email
      suppressSubject: false
      message: The main content or body of the email.
      plainBody: true
      includeTimestamp: true
      localAttachFiles:
        - attach1.txt
        - attach2.txt
      localAttachBase64Contents:
        attach1.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQxIGNvbnRlbnQ=
        attach2.txt: VGhpcyBpcyBhIGF0dGFjaG1lbnQyIGNvbnRlbnQ=
      enableDebugLogging: false

发送 eml 格式文件电子邮件

yaml
- target: SMTP
  name: Send mail eml file message (SMTP)
  description: Using SMTP protocol to send eml file message email
  enabled: true
  server:
    server: 192.168.0.211
    port: 465
    security:
      use: USE_SSL
      trustAllCerts: true
      enforceStartTLS: false
      useLocalTrustStore: false
    useAuth: true
    username: test001@xcan.cloud
    password: test001@xcan
    readTimeout: 60s
    connectTimeout: 6s
  mail:
    mailFrom: test002@xcan.cloud
    receiverTo: test001@xcan.cloud
    content:
      subject: The subject of the email
      suppressSubject: false
      plainBody: false
      sendEmlMessage: true
      localEmlMessageBase64Content: VGhpcyBpcyBhIGVtYWlsIGNvbnRlbnQ=
      enableDebugLogging: false

基于 GPL-3.0 许可发布