smtp: fix sending message to plaintext and encrypted recipients
This commit is contained in:
parent
d738fab6d7
commit
9569e66ccb
|
@ -145,6 +145,7 @@ func main() {
|
|||
s.Addr = "127.0.0.1:" + port
|
||||
s.Domain = "localhost" // TODO: make this configurable
|
||||
s.AllowInsecureAuth = true // TODO: remove this
|
||||
//s.Debug = os.Stdout
|
||||
|
||||
log.Println("Starting SMTP server at", s.Addr)
|
||||
log.Fatal(s.ListenAndServe())
|
||||
|
|
|
@ -4,6 +4,7 @@ package protonmail
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -23,7 +24,8 @@ type resp struct {
|
|||
|
||||
func (r *resp) Err() error {
|
||||
if err := r.apiError; err != nil {
|
||||
return r.apiError
|
||||
err.code = r.Code
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -33,11 +35,12 @@ type maybeError interface {
|
|||
}
|
||||
|
||||
type apiError struct {
|
||||
code int // populated by resp
|
||||
Message string `json:"Error"`
|
||||
}
|
||||
|
||||
func (err apiError) Error() string {
|
||||
return err.Message
|
||||
return fmt.Sprintf("[%v] %v", err.code, err.Message)
|
||||
}
|
||||
|
||||
// Client is a ProtonMail API client.
|
||||
|
|
|
@ -237,7 +237,7 @@ func (u *user) Send(from string, to []string, r io.Reader) error {
|
|||
|
||||
if len(resp.Keys) == 0 {
|
||||
plaintextRecipients = append(plaintextRecipients, rcpt.Address)
|
||||
break
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: only keys with Send == 1
|
||||
|
|
Loading…
Reference in New Issue