跳转至

EmailAuthtimeController(企业域邮件配置)

按企业域读取 / 更新邮件相关配置(SMTP / 收件服务器 / 发件人 / 抄送 / 各类邮箱文件夹路径等),写入 DomainVO 持久化。

  • 类级基址:${myapps.context-path.manager:}/api/authtime(完整路径:{manager-context}/api/authtime<相对路径>)
  • Tag:邮件配置模块(源码 Swagger v2 @Api(tags = "邮件配置模块"),未声明 v3 @Tag)
  • 控制器源码:obpm-manager/src/main/java/cn/myapps/manager/authtime/controller/email/EmailAuthtimeController.java
  • 公共说明:
  • 类继承 BaseAuthTimeController,通过其 success(errmsg, data) / error(errcode, errmsg, errors) 返回统一 Resource(字段 errcode/errmsg/data/errors,结构见 ../index.md「统一响应结构」)。
  • 两端点均在 try/catch 内捕获 Exception 并 e.printStackTrace() 后返回 errcode=500、errmsg=e.getMessage()、data=null(HTTP 状态码 200)。
  • 鉴权说明见 index.md「鉴权说明」(adminToken JWT)。
  • 路径变量 domainid 为企业域 id。

1. 获取企业域邮件配置

读取企业域的邮件相关字段(DomainVO),并把未设置的若干字段回填为源码内默认值(如 IMAP/SMTP 端口、文件夹名等),返回 DomainVoEmailConfig 视图对象。

  • 接口类型:REST 资源
  • 请求方式:GET
  • 请求路径:/domain/{domainid}/email(完整:{manager-context}/api/authtime/domain/{domainid}/email)
  • 鉴权:是(需管理员 adminToken,详见 index.md「鉴权说明」)
  • Tag:邮件配置模块

请求参数

参数名 位置 类型 必填 说明
domainid path string 是 企业域 id

请求示例

GET /api/authtime/domain/__P1UD2yVWpnFpUedONr/email HTTP/1.1

响应

结构:统一 Resource。 data:JSONObject(由 DomainVoEmailConfig 序列化),字段:

字段 类型 说明
domainId string 企业域 id
sendHost string 发件服务器主机
sendAddress string 发件地址
sendAccount string 发件账号
sendPassword string 发件密码
ccAddress string 抄送地址
isUseClient string 是否使用客户端邮件模式
functionDomain string 功能域,缺省回填 dev04.com
trash string 已删除文件夹名,缺省 Junk E-mail
sender string 已发送文件夹名,缺省 Sent Items
draft string 草稿箱文件夹名,缺省 Drafts
removed string 彻底删除标记,缺省 removed
fetchServer string 收件服务器,缺省 192.168.0.120
fetchServerPort string 收件服务器端口,缺省 143(注:源码在两处分别默认 143 与 25,后一处覆盖前一处,最终为 25)
fetchProtocol string 收件协议,缺省 imap
fetchssl string/boolean 收件是否启用 SSL
smtpServer string SMTP 服务器,缺省 192.168.0.120
smtpAuthenticated string/boolean SMTP 是否启用认证
smtpssl string/boolean SMTP 是否启用 SSL
smtpServerPort string SMTP 服务器端口

注:若 DomainVO 为 null(企业域未配置邮件),返回空对象 {}。

成功示例:

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "domainId": "__P1UD2yVWpnFpUedONr",
    "sendHost": "smtp.example.com",
    "sendAddress": "no-reply@example.com",
    "sendAccount": "no-reply@example.com",
    "sendPassword": "***",
    "ccAddress": "",
    "isUseClient": "0",
    "functionDomain": "dev04.com",
    "trash": "Junk E-mail",
    "sender": "Sent Items",
    "draft": "Drafts",
    "removed": "removed",
    "fetchServer": "192.168.0.120",
    "fetchServerPort": "25",
    "fetchProtocol": "imap",
    "fetchssl": "false",
    "smtpServer": "192.168.0.120",
    "smtpAuthenticated": "true",
    "smtpssl": "false",
    "smtpServerPort": "25"
  },
  "errors": null
}
失败示例:
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


2. 更新企业域邮件配置

按请求体 JSON 字段更新企业域 DomainVO 的邮件相关字段,并 doCreateOrUpdate 持久化。

  • 接口类型:REST 资源
  • 请求方式:PUT
  • 请求路径:/domain/{domainid}/email(完整:{manager-context}/api/authtime/domain/{domainid}/email)
  • 鉴权:是
  • Tag:邮件配置模块

请求参数

参数名 位置 类型 必填 说明
domainid path string 是 企业域 id
jsonObj body JSON 是 邮件配置包体(字段见下)

请求体

JSON 对象(application/json),字段(与「获取企业域邮件配置」响应字段一一对应,以下为常用字段):

字段 类型 必填 说明
sendHost string 否 发件服务器主机
sendAddress string 否 发件地址
sendAccount string 否 发件账号
sendPassword string 否 发件密码
ccAddress string 否 抄送地址
isUseClient string 否 是否使用客户端邮件模式
functionDomain string 否 功能域
trash string 否 已删除文件夹名
sender string 否 已发送文件夹名
draft string 否 草稿箱文件夹名
removed string 否 彻底删除标记
fetchServer string 否 收件服务器
fetchServerPort string 否 收件服务器端口
fetchProtocol string 否 收件协议
fetchssl string 否 收件是否启用 SSL
smtpServer string 否 SMTP 服务器
smtpAuthenticated string 否 SMTP 是否启用认证
smtpssl string 否 SMTP 是否启用 SSL
smtpServerPort string 否 SMTP 服务器端口

注:控制器以 jsonObj.getString(field) 取值(字段缺失时为 null),逐字段覆盖 DomainVO,未提供的字段会被置为 null。

请求示例

PUT /api/authtime/domain/__P1UD2yVWpnFpUedONr/email HTTP/1.1
Content-Type: application/json

{
  "sendHost": "smtp.example.com",
  "sendAddress": "no-reply@example.com",
  "sendAccount": "no-reply@example.com",
  "sendPassword": "***",
  "smtpServer": "smtp.example.com",
  "smtpServerPort": "25",
  "smtpAuthenticated": "true",
  "smtpssl": "false",
  "fetchServer": "imap.example.com",
  "fetchServerPort": "143",
  "fetchProtocol": "imap",
  "fetchssl": "false"
}

响应

结构:统一 Resource。 data:字符串 "保存成功"。

条件 errcode errmsg data
企业域 DomainVO 存在且保存成功 0 ok 保存成功
企业域 DomainVO 不存在(未做任何写入) 0 ok 保存成功(仍返回成功)
抛异常 500 <异常信息> null

成功示例:

{ "errcode": 0, "errmsg": "ok", "data": "保存成功", "errors": null }
失败示例:
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }