Skip to content

Commit

Permalink
Merge pull request #6 from xuqingfeng/patch-refactor
Browse files Browse the repository at this point in the history
Patch refactor
  • Loading branch information
xuqingfeng authored Apr 20, 2018
2 parents 5ade2f2 + ad1936f commit 3e646c5
Show file tree
Hide file tree
Showing 23 changed files with 136 additions and 2,020 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea

mailman
out
out/*
!out/.gitkeep
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
language: go
go:
- 1.8
- 1.x
- tip
os:
- linux
install:
- go get github.com/rakyll/statik
- go get -v ./...
script:
- go test -v ./...
- make test
- make build-all

deploy:
provider: releases
api_key:
secure: B5T7Z7NA+/kgsPlEBDKrPfhb1LFeG3tqf3uIydfpR+rQWwAYcRzP8aGqxwSiwTOMYJ6nDuX7Gb3XUWN/Tbl9hoS489PVv/vFLCqd58Da8ATn9aPUy0KIKh/qllIkP/y2RCp4zj1vVtXSNx2udFqX7C4Pc4Fe6F4KY3Da605drpWyKejpqmqvr8xOA5QBVjnfsRh9QbT2lgDheraV6LzHXGB9XFTKfNvBXsr+VzwVOr5v+iiUw/vKo+4sawcrDNwzl14gP7RpRX3itiQTTRmxNR8cpy61tiPP344FTfkQ1S44oICY27tDC4/ez5hrD/y1blLu0YImQXcTvgGql63bvMPSa205HjjbtxR2JBOGYzsYoL5I8+D+NfdgBXr3rtXy3YyOLSHxmnFAERnupcvHrpbc6R7FmKZgHFwTAtWX0Ggu+ABPbJNF1MS25WIfYScDZJL2JUQe+0TZ11u2M90B0gZGWwdlMHZhHv7dtkWipxM7PJw+NzJxu068bIP1pBjZrUKqhpaPuiEjQE7X5SE8cBMEtt0ToKZe2bcbB2ChvlDYfudLoOfCLEQXkrKjL1O7rOZ/+7veFleb2W8erCY8VbrZwMfdfLGcKsZJOjLvgaWWwDba8yBVCgb+AdKwdvA8uaHaDcvZjUjuvMYfYIwMFkfQltevuQeVT71UYhxD56A=
file_golb: true
file: out/mailman*
skip_cleanup: true
on:
repo: xuqingfeng/mailman
tags: true
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
VERSION=`git describe --abbrev=0 --tags`

.PHONY: all run

all: run

run: build
./mailman

build: build-template
go-bindata ui/... && go build
build: generate
go build -o mailman main.go

build-template: fmt # TODO: change package name
cd mail && go-bindata -o bindata.go && cd -
generate:
go generate

fmt:
go fmt ./...

test:
go test ./...
go vet ./... && go test -v $$(go list ./... | grep -v /vendor/)

bin:
gox -osarch="linux/amd64 linux/386 linux/arm darwin/amd64 windows/386 windows/amd64"
build-all: fmt generate
GOOS=linux GOARCH=amd64 go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-linux-amd64 main.go && \
GOOS=linux GOARCH=386 go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-linux-386 main.go && \
GOOS=linux GOARCH=arm go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-linux-arm main.go && \
GOOS=darwin GOARCH=amd64 go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-darwin-amd64 main.go && \
GOOS=windows GOARCH=amd64 go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-windows-amd64.exe main.go && \
GOOS=windows GOARCH=386 go build -ldflags "-w -s -X main.version=${VERSION}" -o out/mailman-windows-386.exe main.go
6 changes: 3 additions & 3 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# mailman
>Web email client supporting HTML template and SMTP
>Web email client supporting HTML template and SMTP
[![Travis CI](https://img.shields.io/travis/xuqingfeng/mailman/master.svg)](https://travis-ci.org/xuqingfeng/mailman)
[![Go Report Card](https://goreportcard.com/badge/github.com/xuqingfeng/mailman)](https://goreportcard.com/report/github.com/xuqingfeng/mailman)

[中文](./README.md) | English

[DEMO](https://github.com/xuqingfeng/mailman/wiki/demo)
[DEMO](https://github.com/xuqingfeng/mailman/wiki/Demo)

### Install

```sh
go get -u github.com/xuqingfeng/mailman

mailman
mailman -h
```

or download the binary file [here](https://github.com/xuqingfeng/mailman/releases)
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# mailman
>支持 HTML 模板和 SMTP 的邮件客户端
>支持 HTML 模板和 SMTP 的网页邮件客户端
[![Travis CI](https://img.shields.io/travis/xuqingfeng/mailman/master.svg)](https://travis-ci.org/xuqingfeng/mailman)
[![Go Report Card](https://goreportcard.com/badge/github.com/xuqingfeng/mailman)](https://goreportcard.com/report/github.com/xuqingfeng/mailman)

中文 | [English](./README.en.md)

[演示](https://github.com/xuqingfeng/mailman/wiki/demo)
[演示](https://github.com/xuqingfeng/mailman/wiki/Demo)

### 安装

```sh
go get -u github.com/xuqingfeng/mailman

mailman
mailman -h
```
或者直接下载 [打包文件](https://github.com/xuqingfeng/mailman/releases)
或者直接下载 [二进制文件](https://github.com/xuqingfeng/mailman/releases)

#### 当前默认支持的邮箱

Expand All @@ -24,4 +24,6 @@ mailman
- [Outlook](https://www.outlook.com/)
- [Gmail](https://mail.google.com/)

*注意:*

关于 Gmail 无法发送邮件问题,查看这里: [https://support.google.com/mail/answer/14257](https://support.google.com/mail/answer/14257)
10 changes: 2 additions & 8 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import (

var (
testAccount = Account{
"test@example.com",
"password",
}
test1Account = Account{
"test1@example.com",
"password1",
Email: "test@example.com",
Password: "password",
}
)

Expand All @@ -22,7 +18,6 @@ func TestSaveAccount(t *testing.T) {
if err != nil {
t.Errorf("SaveAccount() fail %v", err)
}
SaveAccount(test1Account)
}
func TestGetAccountEmail(t *testing.T) {

Expand Down Expand Up @@ -53,7 +48,6 @@ func TestDeleteAccount(t *testing.T) {
if err != nil {
t.Errorf("DeleteAccount() fail %v", err)
}
DeleteAccount("test1@example.com")
}

func TestEncryptPassword(t *testing.T) {
Expand Down
1,454 changes: 0 additions & 1,454 deletions bindata.go

This file was deleted.

55 changes: 0 additions & 55 deletions handlers_test.go

This file was deleted.

350 changes: 0 additions & 350 deletions mail/bindata.go

This file was deleted.

3 changes: 1 addition & 2 deletions mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func ParseMailContent(body string) (content string) {
content = string(parsedContent)

// credit: https://github.com/leemunroe/responsive-html-email-template
// if responsive.html changes, run `go-bindata .`
mailTemplateContent, err := Asset(util.MailTemplateType + ".html")
mailTemplateContent, err := util.GetContentFromStatik("/" + util.MailTemplateType + ".html")
if err != nil {
util.FileLog.Warn(err.Error())
return
Expand Down
12 changes: 6 additions & 6 deletions mail/mail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
func TestMain(m *testing.M) {

account4mail := account.Account{
"from@example.com",
"password",
Email: "from@example.com",
Password: "password",
}
smtp4mail := smtp.SMTPServer{
"@example.com",
"smtp.example.com",
"25",
Address: "@example.com",
Server: "smtp.example.com",
Port: "25",
}
account.SaveAccount(account4mail)
smtp.SaveSMTPServer(smtp4mail)
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestSendMail(t *testing.T) {
func TestParseMailContent(t *testing.T) {

// mail-template not exist
content := ParseMailContent("")
content := ParseMailContent("test")
if len(content) == 0 {
t.Error("ParseMailContent() fail")
}
Expand Down
Loading

0 comments on commit 3e646c5

Please sign in to comment.