Skip to content
Inline styling for html mail in golang
Branch: master
Clone or download
Latest commit ac25997 May 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd Split up cmd. Add an empty test to make sure it build for now Apr 5, 2019
premailer #8 gofmt -w -s May 2, 2019
.gitignore More gitignore May 5, 2015
.travis.yml Step up go version May 4, 2019
LICENSE Adding license Feb 22, 2015
Makefile Adding gocyclo check May 4, 2019
README.md Adding links May 1, 2019

README.md

go-premailer

Inline styling for HTML mail in golang

Document

Build Status GoDoc GoCover Go Report Card

install

go get github.com/vanng822/go-premailer/premailer

Example

import (
	"fmt"
	"github.com/vanng822/go-premailer/premailer"
	"log"
)

func main() {
	prem, err := premailer.NewPremailerFromFile(inputFile, premailer.NewOptions())
	if err != nil {
		log.Fatal(err)
	}
	
	html, err := prem.Transform()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(html)
}

Input

<html>
<head>
<title>Title</title>
<style type="text/css">
	h1 { width: 300px; color:red; }
	strong { text-decoration:none; }
</style>
</head>
<body>
	<h1>Hi!</h1>
	<p><strong>Yes!</strong></p>
</body>
</html>

Output

<html>
<head>
<title>Title</title>
</head>
<body>
	<h1 style="color:red;width:300px" width="300">Hi!</h1>
	<p><strong style="text-decoration:none">Yes!</strong></p>
</body>
</html>

Commandline

> go run main.go -i your_email.html
> go run main.go -i your_mail.html -o process_mail.html

Demo

http://premailer.isgoodness.com/

Conversion endpoint

http://premailer.isgoodness.com/convert

request POST:
	html: your mail
	cssToAttributes: true|false
	removeClasses: true|false
response:
	{result: output}
You can’t perform that action at this time.