This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.go
54 lines (49 loc) · 2.23 KB
/
mail.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
// Subject: <your-subject>
// Content-Type: multipart/mixed; boundary="-unique-str"
//
// ---unique-str
// Content-Type: text/html
// Content-Disposition: inline
//
// <html-body here>
// ---unique-str
// Content-Type: application; name=<attachment-mime>
// Content-Transfer-Encoding: base64
// Content-Disposition: attachment; filename=<attachment-name>
//
// <your base64-encoded attachment here>
// ---unique-str--
import (
"log"
"net/smtp"
"os"
)
func main() {
to := []string{"[email protected]"}
body := os.Args[1]
msg := []byte("To: [email protected]\r\n" +
"Subject: noreply new discount Gophers!\r\n" +
"\r\n" +
"nonono This is the email body again" + body + ".\r\n")
err := smtp.SendMail("localhost:25", nil, "[email protected]", to, msg)
log.Println(err)
}
// [root@wutuofu ~]# cat l
// Subject: test again
// Content-Type: multipart/mixed; boundary="-unique-str"
//
// ---unique-str
// Content-Type: text/html
// Content-Disposition: inline
//
// <p>heelo world</p>
// <hr>
// <p>go world</p>
// ---unique-str
// Content-Type: application; name=<attachment-mime>
// Content-Transfer-Encoding: base64
// Content-Disposition: attachment; filename=<attachment-name>
//
// R0lGODlhHAAUAPMFACE5CDlaCHuMa+fn50J7ANaM//+MjP/WjIz///9r9/9rawAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJBQAFACwAAAAAHAAUAAADhFi6PAIQCkZre0GQJ6b9hQMIR3kY2gBWIkAcXReMK8VxGQapddidpJxGQ+CtNKbSJqb0gETJQ2ZZQhkt0KSQJM0cM9EAYcwdfrkmzKtkBmkMUcNMK7hWMFF20voFwPNJbRYyhGh5NFgzhoBpAHYFQ4ySXhcjkowPV3iXjJQKGDGhoqOCCQAh+QQJBQAEACwAAAEAGgATAAAEeJDIOaqoM+ttgxfXsI3SIHhIeoIimZmAkM4IELQuAa+158U4EkgW+5xsgODoRFvxWC5YMwCiIk7KF2halV0vJJN3RmXOwCMxrXY8oznms20MFQLW7ObQju87szx9eH8ZQ0iCelQ4Jl+BiFdAEnGPfWUETkOZmpsfEQAh+QQJBQAGACwAAAIAFwASAAADcmi6074wwiZqbTIPEYLtwpBNhCcUqBWOxhagXqEG4sidMgB2gDC6KFnBdKNpOEGYKueLVADJ4VJWcUKjRJw0MnhFi1oPVxvklLRVSCUK62Ct3iQSW2txrmw2p7Yx6+J5OSJda089ZFghLh48OjoqMwADCQAh+QQJBQAEACwBAAQAFwAQAAAEcpDISeW4uGo6hAhA6A1b1QFCoRafQJbEmcz0HAiwnNw7KL6aT8H2uRVdmwFvNmwVbxpdzenDVVq1GTUVAMY+WZrxVgB4neEeKFEGKgEJQbocYncnwrg87NEiPQFDNiAqaShfAIJMKlhZh28ekZE+RpM4EQAh+QQFBQAEACwBAAEAGgATAAAEeZDISSsZeNjNb+4gFgijIGgghZFAoLABmg4sKSi4LXO0iwO3gLC12/RwSFutqCIhkybYiWd65koBA1DAcVpfWFPL2PqCxb/ABmYeAtIWr89ag6vm1W8ZDLjPFX9tUxIDe0hDgYeDNDdmL41WIxcsjpU/GoWImpucJxEAOw==
// ---unique-str--