tencent_yun.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. type TencentEmail struct {
  10. Client *ses.Client
  11. }
  12. func (te *TencentEmail) NewClient() (err error) {
  13. if utils.TencentSDKSecretId == `` {
  14. err = errors.New("腾讯云邮箱未配置")
  15. return
  16. }
  17. credential := common.NewCredential(
  18. utils.TencentSDKSecretId,
  19. utils.TencentSDKSecretKey,
  20. )
  21. cpf := profile.NewClientProfile()
  22. cpf.HttpProfile.Endpoint = "ses.tencentcloudapi.com"
  23. client, _err := ses.NewClient(credential, "ap-hongkong", cpf)
  24. te.Client = client
  25. err = _err
  26. return
  27. }
  28. type TencentEmailCallBack struct {
  29. Event string `description:"事件类型"`
  30. Email string `description:"收件人地址"`
  31. Link string `description:"用户点击的邮件中的链接 URL,仅在event=click时生效"`
  32. BulkId string `description:"SendEmail 接口返回的 MessageId"`
  33. Timestamp int `description:"事件产生的时间戳"`
  34. Reason string `description:"邮件递送失败的原因"`
  35. BounceType string `description:"如果收件人邮件服务商拒信,拒信类型,取值:soft_bounce | hard_bounce,仅在event=bounce的时候生效"`
  36. Username string `description:"腾讯云账号对应的 appId"`
  37. From string `description:"发信地址(不带发件人别名)"`
  38. FromDomain string `description:"发信域名"`
  39. TemplateId int `description:"模板 Id"`
  40. }