package main

import (
	"net/smtp"
)

type Email struct {
	Recipients []string
	Host string
	Port string
	From string
	Username string
	Password string
}

func main() {
	e := Email{
		Recipients: []string{"baz@foo.com"},
		Host:       "smtp.foo.com",
		Port:       "587",
		From:       "from@foo.com",
		Username:   "foo",
		Password:   "bar",
	}
	auth := smtp.PlainAuth("", e.Username, e.Password, e.Host)
	err := smtp.SendMail(e.Host+":"+e.Port, auth, e.From, e.Recipients, []byte(data))
	if err != nil {
		println(err.Error())
	} else {
		println("Successfully sent email")
	}
}

var data = `
From: %s
To: %s
Subject: TEST EMAIL
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="e255104e821101849e9aefa6986"

--e255104e821101849e9aefa6986
Content-Type: text/plain; charset=UTF-8

THIS IS A TEST

--e255104e821101849e9aefa6986
Content-Type: text/html; charset=UTF-8

<b>THIS IS A TEST</b>

--e255104e821101849e9aefa6986--