all repos — mail2 @ 9a4ef3d0b7c18f00d1174cc0582ffadfb4600689

fork of github.com/joegrasse/mail with some changes

README.md (view raw)

 1The best way to send emails in Go.
 2
 3**Download**
 4
 5```bash
 6go get github.com/joegrasse/mail
 7```
 8
 9**Basic Usage**
10
11```go
12package main
13
14import (
15	"fmt"
16	"github.com/joegrasse/mail"
17)
18
19func main() {
20	var err error
21	email := mail.New()
22
23	email.SetFrom("From Example <from@example.com>")
24	email.AddTo("to@example.com")
25	email.SetSubject("New Go Email")
26
27	email.SetBody("text/plain", "Hello Gophers!")
28
29	html_body :=
30		`<html>
31	<head>
32	   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
33	   <title>Html Email Test!</title>
34	</head>
35	<body>
36	   <p>Hello <b>Gophers</b>!</p>
37	   <p><img src="cid:image.jpg" alt="image" /></p>
38	</body>
39	</html>`
40	email.AddAlternative("text/html", html_body)
41
42	email.AddInline("/path/to/image.jpg")
43
44	err = email.Send("smtp.example.com:25")
45	
46	if err != nil {
47		fmt.Println(err)
48	} else {
49		fmt.Println("Email Sent!")
50	}
51}
52```