diff --git a/mailHelper.go b/mailHelper.go index 36d623b..6173aee 100644 --- a/mailHelper.go +++ b/mailHelper.go @@ -24,13 +24,20 @@ func send(e Email, api keybase.ChatAPI) { log.LogDebug(message) log.LogInfo("Sending message") chat.React(api.Msg.ID, ":mailbox_with_no_mail:") + if conf.KeyPass == "" { + chat.React(api.Msg.ID, ":unlock:") + } else { + chat.React(api.Msg.ID, ":lock_with_ink_pen:") + } err := smtp.SendMail(conf.SmtpServer, smtp.PlainAuth("", conf.MyEmail, conf.EmailPass, conf.AuthServer), conf.MyEmail, e.Recipients, []byte(message)) + chat.React(api.Msg.ID, ":mailbox_with_no_mail:") if err != nil { log.LogErrorType(err) + chat.React(api.Msg.ID, ":warning:") + return } - chat.React(api.Msg.ID, ":mailbox_with_no_mail:") chat.React(api.Msg.ID, ":mailbox_with_mail:") log.LogInfo("Email Sent") } diff --git a/main.go b/main.go index 78cf18e..ad2cbbf 100644 --- a/main.go +++ b/main.go @@ -131,16 +131,22 @@ func loadConfig() Config { return c } func setupCredentials() { - log.LogCritical("Enter pgp key passphrase:") + log.LogCritical("Enter optional pgp key passphrase:") bytePass, err := terminal.ReadPassword(int(syscall.Stdin)) if err != nil { log.LogCritical(fmt.Sprintf("Error reading pgp password:\n```%+v```", err)) } conf.KeyPass = strings.TrimSpace(string(bytePass)) - log.LogCritical("Enter email passphrase:") - bytePass, err = terminal.ReadPassword(int(syscall.Stdin)) - if err != nil { - log.LogCritical(fmt.Sprintf("Error reading email password:\n```%+v```", err)) + if conf.KeyPass == "" { + log.LogCritical("Starting without PGP signature capabilities.") + } + for i := len(conf.EmailPass); i < 1; i = len(conf.EmailPass) { + log.LogCritical("Enter required email passphrase:") + bytePass, err = terminal.ReadPassword(int(syscall.Stdin)) + if err != nil { + log.LogCritical(fmt.Sprintf("Error reading email password:\n```%+v```", err)) + } + conf.EmailPass = strings.TrimSpace(string(bytePass)) + } - conf.EmailPass = strings.TrimSpace(string(bytePass)) } diff --git a/pgpHelper.go b/pgpHelper.go index 2f579d4..5c434be 100644 --- a/pgpHelper.go +++ b/pgpHelper.go @@ -39,6 +39,9 @@ func getPrivateKey() *openpgp.Entity { } func signMessage(m string) string { + if conf.KeyPass == "" { + return m + } pk := getPrivateKey() out := new(bytes.Buffer) in, err := clearsign.Encode(out, pk.PrivateKey, nil)