Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Blackfriday issue; provides explicit v2 #68

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: go

go:
- 1.13
- 1.14

script:
- go test -race -coverprofile=coverage.txt -covermode=atomic
- cd v2; go test -race -coverprofile=coverage.txt -covermode=atomic

after_success:
- bash <(curl -s https://codecov.io/bash)
- cd v2; bash <(curl -s https://codecov.io/bash)

env:
- GO111MODULE=on
111 changes: 111 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/Masterminds/sprig"
version = "2.14.1"

[[constraint]]
name = "github.com/imdario/mergo"
version = "0.2.4"

[[constraint]]
branch = "master"
name = "github.com/jaytaylor/html2text"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.1.4"

[[constraint]]
name = "gopkg.in/russross/blackfriday.v2"
version = "2.0.0"
58 changes: 9 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/matcornic/hermes)](https://goreportcard.com/report/github.com/matcornic/hermes)
[![Go Coverage](https://codecov.io/github/matcornic/hermes/coverage.svg)](https://codecov.io/github/matcornic/hermes/)
[![Godoc](https://godoc.org/github.com/matcornic/hermes?status.svg)](https://godoc.org/github.com/matcornic/hermes)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmatcornic%2Fhermes.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmatcornic%2Fhermes?ref=badge_shield)

Hermes is the Go port of the great [mailgen](https://github.com/eladnava/mailgen) engine for Node.js. Check their work, it's awesome!
It's a package that generates clean, responsive HTML e-mails for sending transactional e-mails (welcome e-mails, reset password e-mails, receipt e-mails and so on), and associated plain text fallback.

# v2

The latest version is [**v2**](v2/README.md) - please refer to [the README for v2](v2/README.md) for new developments.

What follow provides maintenance for the older **v1**.

# Demo

<img src="screens/default/welcome.png" height="400" /> <img src="screens/default/reset.png" height="400" /> <img src="screens/default/receipt.png" height="400" />
Expand All @@ -18,12 +23,9 @@ It's a package that generates clean, responsive HTML e-mails for sending transac
First install the package:

```
go get -u github.com/matcornic/hermes/v2
go get -u github.com/matcornic/hermes
```

> Starting from release *v2.0.0*, Hermes uses [Go modules](https://github.com/golang/go/wiki/Modules). The latest version of Hermes requires at least Go 1.11 with gomodules enabled.
> You can still use an Hermes release compatible with prior Go versions by using *v1.2.0* release

Then, start using the package by importing and configuring it:

```go
Expand Down Expand Up @@ -92,7 +94,6 @@ This code would output the following HTML template:
And the following plain text:

```

------------
Hi Jon Snow,
------------
Expand All @@ -113,25 +114,12 @@ Copyright © 2017 Hermes. All rights reserved.

## More Examples

* [Welcome with button](examples/welcome.go)
* [Welcome with invite code](examples/invite_code.go)
* [Welcome](examples/welcome.go)
* [Receipt](examples/receipt.go)
* [Password Reset](examples/reset.go)
* [Maintenance](examples/maintenance.go)

To run the examples, go to `examples` folder, then run `go run -a *.go`. HTML and Plaintext example should be created in given theme folders.

Optionaly you can set the following variables to send automatically the emails to one your mailbox. Nice for testing template in real email clients.

* `HERMES_SEND_EMAILS=true`
* `HERMES_SMTP_SERVER=<smtp_server>` : for Gmail it's `smtp.gmail.com`
* `HERMES_SMTP_PORT=<smtp_port>` : for Gmail it's `465`
* `HERMES_SENDER_EMAIL=<your_sender_email>`
* `HERMES_SENDER_IDENTITY=<the sender name>`
* `HERMES_SMTP_USER=<smtp user>` : usually the same than `HERMES_SENDER_EMAIL`
* `HERMES_TO=<recipients emails>`: split by commas like `[email protected],[email protected]`

The program will ask for your SMTP password. If needed, you can set it with `HERMES_SMTP_PASSWORD` variable (but be careful where you put this information !)
To run the examples, go to `examples` folder, then run `go run *.go`. HTML and Plaintext example should be created in given theme folders.

## Plaintext E-mails

Expand Down Expand Up @@ -224,16 +212,6 @@ h := hermes.Hermes{
}
```

Since `v2.1.0`, Hermes is automatically inlining all CSS to improve compatibility with email clients, thanks to [Premailer](https://github.com/vanng822/go-premailer/premailer).
You can disable this feature by setting `DisableCSSInlining` of `Hermes` struct to `true`.

```go
h := hermes.Hermes{
...
DisableCSSInlining: true,
}
```

## Elements

Hermes supports injecting custom elements such as dictionaries, tables and action buttons into e-mails.
Expand All @@ -259,21 +237,6 @@ email := hermes.Email{
}
```

Alternatively, instead of having a button, an action can be an invite code as follows:

```go
email := hermes.Email{
Body: hermes.Body{
Actions: []hermes.Action{
{
Instructions: "To get started with Hermes, please use the invite code:",
InviteCode: "123456",
},
},
},
}
```

To inject multiple action buttons in to the e-mail, supply another struct in Actions slice `Action`.

### Table
Expand Down Expand Up @@ -414,6 +377,3 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)

Apache 2.0



[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmatcornic%2Fhermes.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmatcornic%2Fhermes?ref=badge_large)
Loading