sendcloud

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// message type: 0表示短信, 1表示彩信,2表示国际短信,3表示国内语音,5表示影音 默认值为0
	MessageTypeCN      = 0 // 短信, 默认值为0
	MessageTypeOversea = 2 // 国际短信
)

Variables

This section is empty.

Functions

func QuickPost

func QuickPost(cli *http.Client, url string, data url.Values) error

post form:

Types

type Email

type Email struct {
	// contains filtered or unexported fields
}

func NewEmail

func NewEmail(apiUser string, apiKey string) *Email

func (*Email) Send

func (m *Email) Send(mail *Mail) error

func (*Email) SendTemplate

func (m *Email) SendTemplate(mail *MailTemplate) error

type Mail

type Mail struct {
	// key:
	ApiUser string `json:"apiUser"` // API_USER
	ApiKey  string `json:"apiKey"`  // API_KEY

	// address:
	AddrFrom string   `json:"from"` // 发件人地址
	AddrTo   []string `json:"to"`   // 收件人地址. 多个地址使用';'分隔, 如 ben@ifaxin.com;joe@ifaxin.com
	AddrCc   []string `json:"cc"`   // 抄送地址. 多个地址使用';'分隔
	AddrBcc  []string `json:"bcc"`  // 密送地址. 多个地址使用';'分隔

	//
	FromName string   `json:"fromName"` // 发件人名称. 显示如: ifaxin客服支持<support@ifaxin.com>
	ReplyTo  []string `json:"replyTo"`  // 设置用户默认的回复邮件地址.多个地址使用';'分隔,地址个数不能超过3个. 如果 replyTo 没有或者为空, 则默认的回复邮件地址为 from

	// content:
	Subject     string   `json:"subject"`     // 标题
	Html        string   `json:"html"`        // 邮件的内容. 邮件格式为 text/html
	Plain       string   `json:"plain"`       // 邮件的内容. 邮件格式为 text/plain
	Headers     string   `json:"headers"`     // 邮件头部信息. JSON 格式, 比如:{"header1": "value1", "header2": "value2"}
	Attachments []string `json:"attachments"` // 邮件附件. 发送附件时, 必须使用 multipart/form-data 进行 post 提交 (表单提交)

	// switch:
	UseNotification bool `json:"useNotification"` // 默认值: false. 是否使用回执
	UseAddressList  bool `json:"useAddressList"`  // 默认值: false. 是否使用地址列表发送
}

Mail email content: https://www.sendcloud.net/doc/email_v2/send_email/

func (*Mail) Default

func (m *Mail) Default(apiUser string, apiKey string)

func (*Mail) ToSend

func (m *Mail) ToSend() url.Values

type MailTemplate

type MailTemplate struct {
	// key:
	ApiUser string `json:"apiUser"` // API_USER
	ApiKey  string `json:"apiKey"`  // API_KEY

}

模板邮件

func (*MailTemplate) Default

func (m *MailTemplate) Default(apiUser string, apiKey string)

func (*MailTemplate) ToSend

func (m *MailTemplate) ToSend() url.Values

type Message

type Message struct {
	SmsUser string `json:"smsUser"` //

	//
	TemplateID int64    `json:"templateId"` // 短信模板ID
	LabelID    int64    `json:"labelId"`    // 短信标签ID
	MsgType    int64    `json:"msgType"`    // 0表示短信, 1表示彩信,2表示国际短信,3表示国内语音,5表示影音 默认值为0
	Phone      []string `json:"phone"`      // 收信人手机号,多个手机号用逗号,分隔,每次调用最大支持2000,更多地址建议使用联系人列表功能
	Vars       string   `json:"vars"`       // 替换变量的json串
	Signature  string   `json:"signature"`  // 数字签名, 合法性验证,详情见API 验证机制
	Timestamp  string   `json:"timestamp"`  // UNIX时间戳
	Tag        string   `json:"tag"`        // 值为json 格式字符串,最大字符长度为128,比如:{"key1": "value1", "key2": "value2"}
}

Message sms message: https://www.sendcloud.net/doc/sms/api/#send

func (*Message) Default

func (m *Message) Default(apiUser string)

func (*Message) Sign

func (m *Message) Sign(smsKey string)

生成签名:

func (*Message) ToSend

func (m *Message) ToSend() url.Values

type MessageVoice

type MessageVoice struct {
	SmsUser string `json:"smsUser"` //

	//
	LabelID   int64  `json:"labelId"`   // 短信标签ID
	Phone     string `json:"phone"`     // 收信人手机号
	Code      string `json:"code"`      // 验证码
	Signature string `json:"signature"` // 数字签名, 合法性验证,详情见API 验证机制
	Timestamp string `json:"timestamp"` // UNIX时间戳
	Tag       string `json:"tag"`       // 值为json 格式字符串,最大字符长度为128,比如:{"key1": "value1", "key2": "value2"}
}

http://www.sendcloud.net/smsapi/sendVoice

func (*MessageVoice) Default

func (m *MessageVoice) Default(apiUser string)

func (*MessageVoice) ToSend

func (m *MessageVoice) ToSend() url.Values

type Option

type Option struct {
	EmailApiUser string // email: user
	EmailApiKey  string // email: key
	SmsApiUser   string // sms: user
	SmsApiKey    string // sms: key
}

type SendCloud

type SendCloud struct {
	// contains filtered or unexported fields
}

func NewSendCloud

func NewSendCloud(opt *Option) *SendCloud

func (*SendCloud) SendEmail

func (m *SendCloud) SendEmail()

func (*SendCloud) SendSms

func (m *SendCloud) SendSms()

type Sms

type Sms struct {
	// contains filtered or unexported fields
}

func NewSms

func NewSms(apiUser string, apiKey string) *Sms

func (*Sms) Send

func (m *Sms) Send(msg *Message) error

func (*Sms) SendVoice

func (m *Sms) SendVoice(msg *MessageVoice) error

Jump to

Keyboard shortcuts

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