vanng822/go-premailer

Inline styling for html mail in golang

Go

208

189 commits

updated Oct 2, 2026

See the code

README

go-premailer

Inline styling for HTML mail in golang

Document

GoDoc 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)

	txt, err := prem.TransformText()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(txt)
}

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 cmd/main.go -i your_email.html
> go run cmd/main.go -i your_mail.html -o process_mail.html
> go run cmd/main.go -i premailer/data/markup_test.html --text
email
golang
html
inline-css
inline-styles
mail
premailer

vanng822/go-premailer

Inline styling for html mail in golang

Go

208

189 commits

updated Oct 2, 2026

See the code

README

go-premailer

Inline styling for HTML mail in golang

Document

GoDoc 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)

	txt, err := prem.TransformText()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(txt)
}

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 cmd/main.go -i your_email.html
> go run cmd/main.go -i your_mail.html -o process_mail.html
> go run cmd/main.go -i premailer/data/markup_test.html --text
email
golang
html
inline-css
inline-styles
mail
premailer

Project health

Overall

5.2/10

Maintained

4/10

Code review

0/10
OpenSSF Scorecard

Latest release

v1.37.0 · Oct 2, 2026

Releases this year

12

Significant stargazers

饺子w (Yumechi)

146 followers · starred Aug 2020

Ruben Fonseca

174 followers · starred Feb 2022