/smtp.go

Simple library for sending utf-8 e-mails and attachments via smtp with golang

Primary LanguageGoMIT LicenseMIT

Smtp.go

Simple library for sending utf-8 e-mails via smtp with golang

License

The MIT License (MIT). Please see License File for more information.

Installation

go get github.com/ozgur-yalcin/smtp.go

Usage

package main

import (
	"fmt"
	"net/mail"

	smtp "github.com/ozgur-yalcin/smtp.go/src"
)

func main() {
	config := smtp.Config{MailHost: "", MailPort: "", MailUser: "", MailPass: ""}
	api := &smtp.API{Config: config}
	api.SetHeaders(mail.Address{"From Name", "from@example.com"}, mail.Address{"To Name", "to@example.com"}, "Title", "Message")
	send := api.Send()
	if send {
		fmt.Println("SENT!")
	} else {
		fmt.Println("ERROR")
	}
}