Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

An easy way to send emails with attachments in Go

Install

go get github.com/scorredoira/email

Basic Usage

package main

import (
    "github.com/scorredoira/email"
    "net/smtp"
)

func main() {
    m := email.NewMessage("Hi", "this is the body")
    m.From = "from@example.com"
    m.To = []string{"to@example.com"}
    m.Cc = []string{"cc1@example.com", "cc2@example.com"}
    m.Bcc = []string{"bcc1@example.com", "bcc2@example.com"}

    err = email.Send("smtp.gmail.com:587", smtp.PlainAuth("", "user", "password", "smtp.gmail.com"), m)
}

Send attachments

m := email.NewMessage("Hi", "this is the body")
m.From = "from@example.com"
m.To = []string{"to@example.com"}
err := m.Attach("picture.png")
if err != nil {
    log.Println(err)
}

err = email.Send("smtp.gmail.com:587", smtp.PlainAuth("", "user", "password", "smtp.gmail.com"), m)

About

An easy way to send emails with attachments in Go

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors