dm

package
v0.0.0-...-ba7e8e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

aliyun direct mail

这个服务支持通过阿里云发送短信以及邮件。 使用接口前需要在控制台设置相关的模版和签名,具体参考DM服务的说明文档:

Direct Mail

调用方法如测试文件中的一样

func TestSms(t *testing.T) {
	ID := os.Getenv("ALI_DM_ACCESS_KEY_ID")
	SECRET := os.Getenv("ALI_DM_ACCESS_KEY_SECRET")
	SIGNAME := os.Getenv("ALI_DM_SMS_SIGN_NAME")
	TEMPCODE := os.Getenv("ALI_DM_SMS_TEMPLATE_CODE")
	NUM := os.Getenv("ALI_DM_SMS_TEST_PHONE")
	client := NewClient(ID, SECRET)
	client.SendSms(SIGNAME, TEMPCODE, NUM, map[string]string{
		"number": "123456",
	})
}

测试这个包,需要设置下面用到的环境变量

	ID := os.Getenv("ALI_DM_ACCESS_KEY_ID")
	SECRET := os.Getenv("ALI_DM_ACCESS_KEY_SECRET")
	SIGNAME := os.Getenv("ALI_DM_SMS_SIGN_NAME")
	TEMPCODE := os.Getenv("ALI_DM_SMS_TEMPLATE_CODE")
	NUM := os.Getenv("ALI_DM_SMS_TEST_PHONE")
	accountName := os.Getenv("ALI_DM_ACCOUNT_NAME")
	templateName := os.Getenv("ALI_DM_TEMPLATE_NAME")
	receiverName := os.Getenv("ALI_DM_RECEIVER_NAME")
	accountName := os.Getenv("ALI_DM_ACCOUNT_NAME")
	replyToAddress := os.Getenv("ALI_DM_REPLY_TO_ADDRESS")
	toAddress := os.Getenv("ALI_DM_TO_ADDRESS")

maintainer: johnzeng

#2016.12.20 将短信API从邮件中分离了出来,并且让DM服务使用Common Client,采用struct形式的参数,与其他服务统一。具体使用方法参见mail_test。 yarous224

Documentation

Index

Constants

View Source
const (
	EmailEndPoint   = "https://dm.aliyuncs.com/"
	SingleSendMail  = "SingleSendMail"
	BatchSendMail   = "BatchSendMail"
	EmailAPIVersion = "2015-11-23"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	common.Client
}

func NewClient

func NewClient(accessKeyId, accessKeySecret string) *Client

func (*Client) SendBatchMail

func (this *Client) SendBatchMail(args *SendBatchMailArgs) error

func (*Client) SendSingleMail

func (this *Client) SendSingleMail(args *SendSingleMailArgs) error

type SendBatchMailArgs

type SendBatchMailArgs struct {
	SendEmailArgs
	TemplateName string
	ReceiverName string
	TagName      string
}

type SendEmailArgs

type SendEmailArgs struct {
	AccountName string
	AddressType string
}

type SendSingleMailArgs

type SendSingleMailArgs struct {
	SendEmailArgs
	ReplyToAddress bool
	ToAddress      string
	FromAlias      string
	Subject        string
	HtmlBody       string
	TextBody       string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL