CLI email sender
This commit is contained in:
32
main.go
Normal file
32
main.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"local/args"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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, "from", "message sender", "breellocaldev@gmail.com")
|
||||
as.Append(args.STRING, "password", "message sender password", "ML3WQRFSqe9rQ8qNkm")
|
||||
as.Append(args.STRING, "smtp", "smtp server:port", "smtp.gmail.com:465")
|
||||
as.Append(args.STRING, "pop3", "pop3 server:port", "pop.gmail.com:995")
|
||||
if err := as.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
emailer := &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