notifier

package module
v0.0.0-...-12228a5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 7 Imported by: 0

README

Notifier

用于给用户发送邮件,短信等等

发送 Email
// 注册一个EmailNotifier 
// 参数依次为:smtp服务器地址,发送账户,发送账户密码
email, err = notifier.NewEmailNotifier("smtp.exmail.qq.com:25", "service@laily.me", "123")
// 参数为:接收方账户,发送邮件的主题和内容,内容支持html形式
email.SendMail("aa@laily.me;bb@laily.me","title","content")
发送 Alertover

Alertover 是一个实现了手机推送的 app,可以将需要推送的内容发送至 alertover 的服务器,然后推送至手机。source 和 receiver 的需要去 www.alertover.com 获取

	source := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	receiver := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	alert := notifier.NewAlertover(s)
	alert.SendAlert(receiver, "title", "content")

Documentation

Overview

通知发送 目前支持邮件和 alertover

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alertover

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

Alertover contain a source Alertover website: https://www.alertover.com/

func NewAlertover

func NewAlertover(source string) *Alertover

NewAlertover create a Alertover instance

func (*Alertover) SendAlert

func (self *Alertover) SendAlert(receiver, title, content string) string

SendAlert to send notification param are receiver alertover id, and message title and content

type EmailNotifier

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

EmailNotifier has param SMTPHost, SMTP account

func NewEmailNotifier

func NewEmailNotifier(host, from, password string) (*EmailNotifier, error)

NewEmailNotifier create a EmailNotifier instance host 邮箱 stmp 地址 from 邮箱地址 password 邮箱密码

func (*EmailNotifier) SendMail

func (m *EmailNotifier) SendMail(receiver string, title string, body string) error

SendMail to send notification to others, Params are receiver emails, separate with ";"; email subject and content; content can be html text

Jump to

Keyboard shortcuts

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