123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package services
- import (
- "errors"
- "eta_gn/eta_api/utils"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
- "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
- ses "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses/v20201002"
- )
- // TencentEmail 腾讯云邮件
- type TencentEmail struct {
- Client *ses.Client
- }
- // NewClient
- func (te *TencentEmail) NewClient() (err error) {
- if utils.TencentSDKSecretId == `` {
- err = errors.New("腾讯云邮箱未配置")
- return
- }
- // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
- // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
- credential := common.NewCredential(
- utils.TencentSDKSecretId,
- utils.TencentSDKSecretKey,
- )
- // 实例化一个client选项,可选的,没有特殊需求可以跳过
- cpf := profile.NewClientProfile()
- cpf.HttpProfile.Endpoint = "ses.tencentcloudapi.com"
- // 实例化要请求产品的client对象,clientProfile是可选的
- client, _err := ses.NewClient(credential, "ap-hongkong", cpf)
- te.Client = client
- err = _err
- return
- }
- // TencentEmailCallBack 回调请求体
- type TencentEmailCallBack struct {
- Event string `description:"事件类型"`
- Email string `description:"收件人地址"`
- Link string `description:"用户点击的邮件中的链接 URL,仅在event=click时生效"`
- BulkId string `description:"SendEmail 接口返回的 MessageId"`
- Timestamp int `description:"事件产生的时间戳"`
- Reason string `description:"邮件递送失败的原因"`
- BounceType string `description:"如果收件人邮件服务商拒信,拒信类型,取值:soft_bounce | hard_bounce,仅在event=bounce的时候生效"`
- Username string `description:"腾讯云账号对应的 appId"`
- From string `description:"发信地址(不带发件人别名)"`
- FromDomain string `description:"发信域名"`
- TemplateId int `description:"模板 Id"`
- }
|