Configure third-party email service
Configure third-party email service
Method name
AuthenticationClient.configEmailProvider
Request parameters
| Name | Type | Is it required | Default value | Description | Sample value |
|---|---|---|---|---|---|
| type | string | Yes | - | Third-party email service provider type: - custom: Custom SMTP Mail service- ali: Ali Enterprise Mailbox- qq: Tencent Enterprise Mailbox- sendgrid: SendGrid Mail Service | custom |
| enabled | boolean | yes | - | Whether to enable. If not enabled, the built-in mail service of GenAuth will be used by default | true |
| smtpConfig | <a SMTPEmailProviderConfigInput | no | - | SMTP mail service configuration | |
| sendGridConfig | <a SendGridEmailProviderConfigInput | no | - | SendGrid mail service configuration | |
| aliExmailConfig | <a AliExmailEmailProviderConfigInput | No | - | Ali Enterprise Email Service Configuration | |
| tencentExmailConfig | <a TencentExmailEmailProviderConfigInput | No | - | 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
| Name | Type | Description |
|---|---|---|
| statusCode | number | Business status code, which can be used to determine whether the operation is successful. 200 means success. |
| message | string | Description |
| apiCode | number | Segment error code, which can be used to get the specific error type. |
| requestId | string | Request ID. It will be returned when the request fails. |
| data | <a EmailProviderDto | Response 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
| Name | Type | Is it required? | Description | Sample value |
|---|---|---|---|---|
| smtp_host | string | Yes | SMTP address | smtp.example.com |
| smtp_port | number | Yes | SMTP port | 465 |
| sender | string | No | Username | test |
| senderPass | string | yes | password | passw0rd |
| secure | boolean | no | whether to enable SSL | true |
SendGridEmailProviderConfigInput
| name | type | is it required | description | example value |
|---|---|---|---|---|
| sender | string | yes | username | test |
| apikey | string | yes | SendGrid API Key, see the SendGrid documentation for details. | xxxxxxxxxx |
AliExmailEmailProviderConfigInput
| Name | Type | Is it required | Description | Sample value |
|---|---|---|---|---|
| sender | string | Yes | Username | test |
| senderPass | string | Yes | Password | passw0rd |
TencentExmailEmailProviderConfigInput
| Name | Type | Is it required | Description | Sample value |
|---|---|---|---|---|
| sender | string | yes | Username | test |
| senderPass | string | yes | Password | passw0rd |
EmailProviderDto
| Name | Type | Is it required | Description | Sample value |
|---|---|---|---|---|
| enabled | boolean | yes | Whether to enable. If not enabled, the built-in mail service of GenAuth will be used by default | true |
| type | string | no | Third-party mail service provider type: - custom: Custom SMTP mail service- ali: Ali Enterprise Mailbox- qq: Tencent Enterprise Mailbox- sendgrid: SendGrid Mail Service | ali |
| smtpConfig | no | SMTP mail service configuration Nested type: <a SMTPEmailProviderConfig. | ||
| sendGridConfig | No | SendGrid email service configuration Nested type: <a SendGridEmailProviderConfig. | ||
| aliExmailConfig | No | Ali enterprise email service configuration Nested type: <a AliExmailEmailProviderConfig. | ||
| tencentExmailConfig | No | Tencent enterprise email service configuration Nested type: <a TencentExmailEmailProviderConfig. |
SMTPEmailProviderConfig
| Name | Type | Required | Description | Sample value |
|---|---|---|---|---|
| smtp_host | string | yes | SMTP address | smtp.example.com |
| smtp_port | number | yes | SMTP port | 465 |
| sender | string | yes | Username | test |
| senderPass | string | yes | Password | passw0rd |
| secure | boolean | yes | Enable SSL | true |
SendGridEmailProviderConfig
| Name | Type | Required | Description | Sample value |
|---|---|---|---|---|
| sender | string | Yes | Username | test |
| apikey | string | Yes | SendGrid API Key, see the SendGrid documentation for details. | xxxxxxxxxx |
AliExmailEmailProviderConfig
| Name | Type | Is it required? | Description | Sample value |
|---|---|---|---|---|
| sender | string | Yes | Username | test |
| senderPass | string | Yes | Password | passw0rd |
TencentExmailEmailProviderConfig
| Name | Type | Is it required? | Description | Sample value |
|---|---|---|---|---|
| sender | string | yes | username | test |
| senderPass | string | yes | password | passw0rd |