rename main.go to send.go
This commit is contained in:
34
send.go
Executable file
34
send.go
Executable file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"local/args"
|
||||
"local/sandbox/contact/contact"
|
||||
)
|
||||
|
||||
func main() {
|
||||
emailer := contact.NewEmailer()
|
||||
as := args.NewArgSet()
|
||||
as.Append(args.STRING, "to", "email destination", "squeaky2x3@gmail.com")
|
||||
as.Append(args.STRING, "subject", "message subject", "go emailer")
|
||||
as.Append(args.STRING, "body", "message content", "go emailer")
|
||||
as.Append(args.STRING, "pop3", "pop3 server:port", "pop.gmail.com:995")
|
||||
as.Append(args.STRING, "password", "message sender password", emailer.Password)
|
||||
as.Append(args.STRING, "from", "message sender", emailer.From)
|
||||
as.Append(args.STRING, "smtp", "smtp server:port", emailer.SMTP)
|
||||
if err := as.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
emailer := &contact.Emailer{
|
||||
From: as.Get("from").GetString(),
|
||||
SMTP: as.Get("smtp").GetString(),
|
||||
POP3: as.Get("pop3").GetString(),
|
||||
Password: as.Get("password").GetString(),
|
||||
}
|
||||
if err := emailer.Send(
|
||||
as.Get("to").GetString(),
|
||||
as.Get("subject").GetString(),
|
||||
as.Get("body").GetString(),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user