Skip to content

jakoubek/emaillib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emaillib

Package in Go for sending emails. Encapsulates jordan-wright/email. Probably not useful for anybody else than me.

Usage

emailer := email.NewClient()
_ := emailer.Sendmail("John Doe", "jd@example.com", "Subject", "Some message")

emailer := email.NewClient()
emailer.To("John Doe", "john@example.com")
emailer.Subject("Subject of message")
emailer.BodyText("A bit of a message")
_ := emailer.Send()

Configuration

Create a new email object with the NewClient function. It takes a variadic number of configuration functions as parameters

Configure SMTP host and port

emailer := email.NewClient(
  email.WithRelayhost("smtp.example.com", 465),
)

Configure authentication

emailer := email.NewClient(
  email.WithAuth("your.name@example.com", "123456789abcde", true),
)

Configure a default sender email address (and name)

emailer := email.NewClient(
  email.WithSender("Example Inc. Customer Service", "info@example.com"),
)

Configure development mode without real sending

emailer := email.NewClient(
  email.WithDontSend(),
)

Combine multiple configuration functions

All possible configuration functions can be combined:

emailer := email.NewClient(
  email.WithRelayhost("smtp.fastmail.com", 465),
  email.WithAuth("your.name@example.com", "123456789abcde"),
  email.WithSender("Example Inc. Customer Service", "info@example.com"),
  email.WithDontSend(),
)

Installation

You can install this package in your project by running:

go get -u github.com/jakoubek/emaillib

About

Package in Go for sending emails via SMTP. Encapsulates https://github.com/jordan-wright/email.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages