Skip to content

Configure third-party email service

Configure third-party email service

Method name

AuthenticationClient.configEmailProvider

Request parameters

NameTypeIs it requiredDefault valueDescriptionSample value
typestringYes-Third-party email service provider type:
- custom: Custom SMTP Mail service
- ali: Ali Enterprise Mailbox
- qq: Tencent Enterprise Mailbox
- sendgrid: SendGrid Mail Service
custom
enabledbooleanyes-Whether to enable. If not enabled, the built-in mail service of GenAuth will be used by defaulttrue
smtpConfig<a SMTPEmailProviderConfigInputno-SMTP mail service configuration
sendGridConfig<a SendGridEmailProviderConfigInputno-SendGrid mail service configuration
aliExmailConfig<a AliExmailEmailProviderConfigInputNo-Ali Enterprise Email Service Configuration
tencentExmailConfig<a TencentExmailEmailProviderConfigInputNo-Tencent Enterprise Email Service Configuration

Sample Code

ts
import { ManagementClient, Models } from "authing-node-sdk";

// Initialize ManagementClient
const managementClient = new ManagementClient({
  // Need to be replaced with your GenAuth Access Key ID
  accessKeyId: "GEN_AUTH_ACCESS_KEY_ID",
  // Need to be replaced with your GenAuth Access Key Secret
  accessKeySecret: "GEN_AUTH_ACCESS_KEY_SECRET",
  // If it is a private deployment customer, you need to set the GenAuth service domain name
  // host: 'https://api.your-authing-service.com'
});

(async () => {
  const result = await managementClient.configEmailProvider({
    enabled: true,
    type: Models.ConfigEmailProviderDto.type.CUSTOM,
    smtpConfig: {
      smtpHost: "smtp.example.com",
      smtpPort: 465,
      sender: "test",
      senderPass: "passw0rd",
      secure: true,
    },
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request Response

Type: EmailProviderRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegment error code, which can be used to get the specific error type.
requestIdstringRequest ID. It will be returned when the request fails.
data<a EmailProviderDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "enabled": true,
    "type": "custom",
    "smtpConfig": {
      "smtp_host": "smtp.example.com",
      "smtp_port": 465,
      "sender": "test",
      "senderPass": "passw0rd",
      "secure": true
    },
    "sendGridConfig": {
      "sender": "test",
      "apikey": "xxxxxxxxxx"
    },
    "aliExmailConfig": {
      "sender": "test",
      "senderPass": "passw0rd"
    },
    "tencentExmailConfig": {
      "sender": "test",
      "senderPass": "passw0rd"
    }
  }
}

Data Structure

SMTPEmailProviderConfigInput

NameTypeIs it required?DescriptionSample value
smtp_hoststringYesSMTP addresssmtp.example.com
smtp_portnumberYesSMTP port465
senderstringNoUsernametest
senderPassstringyespasswordpassw0rd
securebooleannowhether to enable SSLtrue

SendGridEmailProviderConfigInput

nametypeis it requireddescriptionexample value
senderstringyesusernametest
apikeystringyesSendGrid API Key, see the SendGrid documentation for details.xxxxxxxxxx

AliExmailEmailProviderConfigInput

NameTypeIs it requiredDescriptionSample value
senderstringYesUsernametest
senderPassstringYesPasswordpassw0rd

TencentExmailEmailProviderConfigInput

NameTypeIs it requiredDescriptionSample value
senderstringyesUsernametest
senderPassstringyesPasswordpassw0rd

EmailProviderDto

NameTypeIs it requiredDescriptionSample value
enabledbooleanyesWhether to enable. If not enabled, the built-in mail service of GenAuth will be used by defaulttrue
typestringnoThird-party mail service provider type:
- custom: Custom SMTP mail service
- ali: Ali Enterprise Mailbox
- qq: Tencent Enterprise Mailbox
- sendgrid: SendGrid Mail Service
ali
smtpConfignoSMTP mail service configuration Nested type: <a SMTPEmailProviderConfig.
sendGridConfigNoSendGrid email service configuration Nested type: <a SendGridEmailProviderConfig.
aliExmailConfigNoAli enterprise email service configuration Nested type: <a AliExmailEmailProviderConfig.
tencentExmailConfigNoTencent enterprise email service configuration Nested type: <a TencentExmailEmailProviderConfig.

SMTPEmailProviderConfig

NameTypeRequiredDescriptionSample value
smtp_hoststringyesSMTP addresssmtp.example.com
smtp_portnumberyesSMTP port465
senderstringyesUsernametest
senderPassstringyesPasswordpassw0rd
securebooleanyesEnable SSLtrue

SendGridEmailProviderConfig

NameTypeRequiredDescriptionSample value
senderstringYesUsernametest
apikeystringYesSendGrid API Key, see the SendGrid documentation for details.xxxxxxxxxx

AliExmailEmailProviderConfig

NameTypeIs it required?DescriptionSample value
senderstringYesUsernametest
senderPassstringYesPasswordpassw0rd

TencentExmailEmailProviderConfig

NameTypeIs it required?DescriptionSample value
senderstringyesusernametest
senderPassstringyespasswordpassw0rd

Agent infrastructure for identity, memory, and web action.