Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from GGGitBoy/fix-email
Browse files Browse the repository at this point in the history
Fix email
  • Loading branch information
Logan committed Apr 23, 2020
2 parents 741a766 + 7a3a91f commit 98d6671
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- SMTP_PWD: 服务邮箱用户密码
- SMTP_ENDPOINT: SMTP端点
- SMTP_PORT: 服务邮箱端口
- PDF_URL: PDF文件地址
- PDF_PWD: PDF文件密码
- DB_HOST_IP: 数据库地址
- DB_USERNAME: 数据库用户名
- DB_PASSWORD: 数据库密码
Expand Down
8 changes: 5 additions & 3 deletions pkg/apis/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apis
import (
"os"
"strconv"
"strings"
"time"

"github.com/360EntSecGroup-Skylar/excelize"
Expand Down Expand Up @@ -36,10 +37,11 @@ func CollectInformation() {
}

func SendInformation() {
m := gomail.NewMessage()
sends := strings.Split(SMTPRancherTo, ",")

m := gomail.NewMessage()
m.SetAddressHeader("From", "no-reply@rancher.cn", "Rancher Labs 中国")
m.SetHeader("To", SMTPRancherTo)
m.SetHeader("To", sends...)
m.SetHeader("Subject", yesterday+"用户信息")
m.SetBody("text/plain", `从 `+yesterday+` 08:00 ~ `+today+` 08:00,一共有 `+strconv.Itoa(count)+` 人下载了中文文档。`)

Expand Down Expand Up @@ -112,7 +114,7 @@ func DBSelect() {
if err != nil {
logrus.Errorf("Failed time parsed duration : %v", err)
}

yesterday = time.Now().Add(d).Format("2006-01-02")
today = time.Now().Format("2006-01-02")
err = xlsx.SaveAs("/tmp/" + yesterday + ".xlsx")
Expand Down
7 changes: 5 additions & 2 deletions pkg/apis/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ var (
SMTPEndpoint = os.Getenv("SMTP_ENDPOINT")
SMTPPort = os.Getenv("SMTP_PORT")

PDFUrl = os.Getenv("PDF_URL")
PDFPwd = os.Getenv("PDF_PWD")

body = `您好,
您可以通过下面的链接和密码下载 Rancher 中文文档。
下载链接:
https://v2.fangcloud.com/share/2bcac9426816768baa179a8435
` + PDFUrl + `
访问密码:
957f1e
` + PDFPwd + `
Best Regards,
Rancher Labs 源澈科技`
Expand Down

0 comments on commit 98d6671

Please sign in to comment.