bart

package module
v0.0.0-...-b814436 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2018 License: MIT Imports: 15 Imported by: 0

README

Bart

Build Status Go Report Card Codacy Badge

Security

bart uses the net/smtp package, which uses TLS if possible. Still, just to be safe, I explicitly discourage using bart for mission-critical information.

Installation

From source
$ make install
Binaries

You can get them from GitHub releases.

Usage example

You want to send an HTML email stored as a Mustache template in template.mustache. Your configuration (see below) is defined in config.bart.yml.

To preview the rendered emails, call bart without the send -s flag:

$ bart -t template.mustache -c config.bart.yml
Hello, Jane Doe
Send flag not set: opening preview in "chromium-browser"
Send flag not set: opening preview in "chromium-browser"

To send the email, add the send flag -s:

$ bart -t template.mustache -c config.bart.yml -s
Hello, Jane Doe
Please enter your credentials for "smtpserver.xyz.com"
Login: janedoe
Password:
Will send to [[email protected] [email protected]]
Will send to [[email protected] [email protected]]

Since this email will not appear in your provider's Sent folder, bart will send you a BCC copy.

For help, call bart -h.

How to configure

Here's an example config file:

author:
  name: Jane Doe
  email: [email protected]
  browser: chromium-browser

email_server:
    hostname: smtpserver.xyz.com
    port: 123

global_context:
  subject: Global subject

recipients:
  [email protected]:
    salutation: Hi John
    subject: Local subject, overrides global one
  [email protected]:
    salutation: Hello Max

Basically, recipients is a hashmap keyed by recipient email addresses; the values are local contexts specific for each recipient. Notice that local context overrides global one!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeRfc1342

func EncodeRfc1342(someString string) string

EncodeRfc1342 encodes a string according to RFC 1342 See https://tools.ietf.org/html/rfc1342

func EncodeToBase64

func EncodeToBase64(someString string) string

EncodeToBase64 transforms a string to bytes and encodes with Base64

func EncodeToBase64WrapLines

func EncodeToBase64WrapLines(someString string) []byte

EncodeToBase64WrapLines encodes a string with Base64 and inserts linebreaks after every 76 characters

func EscapeHtmlCharacters

func EscapeHtmlCharacters(someBytes []byte) []byte

EscapeHtmlCharacters escapes angle brackets and ampersand for HTML

func ProcessFile

func ProcessFile(templateFilename string, send bool, c *Config) error

Types

type Author

type Author struct {
	Name    string
	Email   string
	Browser string
}

type Config

type Config struct {
	EmailServer   EmailServer       `yaml:"email_server"`
	GlobalContext map[string]string `yaml:"global_context"`
	Author        Author
	Recipients    Recipients
}

func (*Config) ImportFromFile

func (t *Config) ImportFromFile(filename string) error

type Email

type Email interface {
	Send(*EmailServer, *authPair) error
	OpenInBrowser(string) error
	GetRecipients() []string
}

type EmailBuilder

type EmailBuilder interface {
	AddAuthor(*Author) EmailBuilder
	AddRecipient(string) EmailBuilder
	AddContent(string) EmailBuilder
	Build(map[string]string) (Email, error)
}

func NewEmail

func NewEmail() EmailBuilder

type EmailServer

type EmailServer struct {
	Hostname string
	Port     int
}

type Recipients

type Recipients map[string]map[string]string

Recipients contains emails and their respective contexts. First map: Emails as keys Second map: Mustache context

Directories

Path Synopsis
cmd
bart command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL