Example #1
0
func XSendMessage(message Message) (err error) {
	subMessageUrl := "https://api.submail.cn/message/xsend.json"
	kmgDebug.Println(message.Vars)
	response, err := http.PostForm(subMessageUrl, url.Values{
		"appid":     {MessageConfig.Appid},
		"signature": {MessageConfig.Signature},
		"to":        {message.To},
		"project":   {kmgStrconv.InterfaceToString(message.Project)},
		"vars":      {message.Vars},
	})
	defer response.Body.Close()
	if err != nil {
		return err
	}
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return err
	}
	kmgLog.Log("SubMessage", string(body), message)
	data := kmgJson.MustUnmarshalToMapDeleteBOM(body)
	if data["status"] == "error" {
		return errors.New(kmgStrconv.InterfaceToString(data["msg"]))
	}
	return nil

}
Example #2
0
func SendMessage(massage Massege) (err error) {
	massegeApiUrl := "https://api.submail.cn/message/xsend"
	resp, e := http.PostForm(massegeApiUrl, url.Values{
		//		"appid":     {EmailConfig.Appid},
		//		"signature": {EmailConfig.Signature},
		"appid":     {"10111"},
		"signature": {"142a3e0d66c4dda1e918487b1952b26c"},
		"to":        {massage.To},
		"project":   {massage.ProjectId},
	})
	if e != nil {
		return e
	}
	defer resp.Body.Close()
	body, e := ioutil.ReadAll(resp.Body)
	if e != nil {
		return e
	}
	kmgLog.Log("Submail", string(body), massage)
	data := kmgJson.MustUnmarshalToMapDeleteBOM(body)
	if data["status"] == "error" {
		return errors.New(kmgStrconv.InterfaceToString(data["msg"]))
	}
	return nil
}
Example #3
0
func MailBreack(email Mail, u url.Values, submailUrl string) (err error) {
	resp, e := http.PostForm(submailUrl, u)
	if e != nil {
		return e
	}
	defer resp.Body.Close()
	body, e := ioutil.ReadAll(resp.Body)
	if e != nil {
		return e
	}
	kmgLog.Log("Submail", string(body), email)
	data := kmgJson.MustUnmarshalToMapDeleteBOM(body)
	if data["status"] == "error" {
		return errors.New(kmgStrconv.InterfaceToString(data["msg"]))
	}
	return nil
}