Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scorredoira/email
An easy way to send emails with attachments in Go
https://github.com/scorredoira/email
Last synced: 30 days ago
JSON representation
An easy way to send emails with attachments in Go
- Host: GitHub
- URL: https://github.com/scorredoira/email
- Owner: scorredoira
- License: mit
- Archived: true
- Created: 2012-06-19T18:19:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T07:03:36.000Z (over 4 years ago)
- Last Synced: 2024-08-03T17:16:26.335Z (4 months ago)
- Language: Go
- Size: 36.1 KB
- Stars: 254
- Watchers: 14
- Forks: 96
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - scorredoira/email
README
# PROJECT DISCONTINUED
This repository only exists for archival purposes.
---
# email [![Travis-CI](https://travis-ci.org/scorredoira/email.svg?branch=master)](https://travis-ci.org/scorredoira/email) [![GoDoc](https://godoc.org/github.com/scorredoira/email?status.svg)](http://godoc.org/github.com/scorredoira/email) [![Report card](https://goreportcard.com/badge/github.com/scorredoira/email)](https://goreportcard.com/report/github.com/scorredoira/email)
An easy way to send emails with attachments in Go
# Install
```bash
go get github.com/scorredoira/email
```# Usage
```go
package email_testimport (
"log"
"net/mail"
"net/smtp""github.com/scorredoira/email"
)func Example() {
// compose the message
m := email.NewMessage("Hi", "this is the body")
m.From = mail.Address{Name: "From", Address: "[email protected]"}
m.To = []string{"[email protected]"}// add attachments
if err := m.Attach("email.go"); err != nil {
log.Fatal(err)
}// add headers
m.AddHeader("X-CUSTOMER-id", "xxxxx")// send it
auth := smtp.PlainAuth("", "[email protected]", "pwd", "smtp.zoho.com")
if err := email.Send("smtp.zoho.com:587", auth, m); err != nil {
log.Fatal(err)
}
}
```# Html
```go
// use the html constructor
m := email.NewHTMLMessage("Hi", "this is the body")
```# Inline
```go
// use Inline to display the attachment inline.
if err := m.Inline("main.go"); err != nil {
log.Fatal(err)
}
```