tencent_yun.go 2.0 KB

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