# README
EmailSender
简介
自用的邮件发送工具
如何使用
配置
配置相关信息
type EmailConfig struct {
Smtp string `yaml:"Smtp"` //smtp 地址
Port string `yaml:"Port"` //端口
From string `yaml:"From"` //用于发送邮件的邮箱
From_code string `yaml:"From_code"` //授权码
}
手动配置
InitEmailConfig(&emailSender{
Smtp :"smtp",
Port :"port"
From :"from"
From_code :"from_code"
})
当程序使用了viper时
InitEmailConfigWithViper()
接口描述
type EmailSender interface {
SendEmail() error
}
实现的对象
type OneSender struct {
To string
Subject string
Body string
}
type Senders struct {
Sends []OneSender
}
type SenderSame struct {
To []string
Subject string
Body string
}
如何调用
发送单个邮件
email := NewOneSender(&OneSender{
To: "[email protected]",
Subject: "Test Subject",
Body: "Test Body",
})
email.SendEmail()
发送多个邮件
emails := NewSenders(&Senders{
Sends: []OneSender{
{
To: "[email protected]",
Subject: "Test Subject1",
Body: "Test Body1",
},
{
To: "[email protected]",
Subject: "Test Subject2",
Body: "Test Body2",
},
}
})
emails.SendEmail()
群发单个邮件
emails := NewSenderSame(&SenderSame{
To: []string{
"[email protected]",
"[email protected]",
"[email protected]",
},
Subject: "Test Send Same Text to Different MailBox",
Body: "Hello World!",
})
# Functions
No description provided by the author
No description provided by the author
当程序利用viper读取配置文件时,可以利用此函数快速船舰 email:
Smtp : "smtp.email.com" Port : "port" From : "[email protected]" From_code : "authorize_code".
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author