smtp: add more logging

This commit is contained in:
Simon Ser 2019-07-13 11:48:15 +03:00
parent 6e41a22e6e
commit f96cf313a8
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"log"
"strings" "strings"
"github.com/emersion/go-message/mail" "github.com/emersion/go-message/mail"
@ -118,6 +119,8 @@ func (s *session) Data(r io.Reader) error {
} }
// Create an empty draft // Create an empty draft
log.Println("creating draft message")
plaintext, err := msg.Encrypt([]*openpgp.Entity{privateKey}, privateKey) plaintext, err := msg.Encrypt([]*openpgp.Entity{privateKey}, privateKey)
if err != nil { if err != nil {
return err return err
@ -206,6 +209,8 @@ func (s *session) Data(r io.Reader) error {
return fmt.Errorf("cannot generate attachment key: %v", err) return fmt.Errorf("cannot generate attachment key: %v", err)
} }
log.Printf("uploading message attachment %q", filename)
pr, pw := io.Pipe() pr, pw := io.Pipe()
go func() { go func() {
@ -235,6 +240,8 @@ func (s *session) Data(r io.Reader) error {
} }
// Encrypt the body and update the draft // Encrypt the body and update the draft
log.Println("uploading message body")
msg.MIMEType = bodyType msg.MIMEType = bodyType
plaintext, err = msg.Encrypt([]*openpgp.Entity{privateKey}, privateKey) plaintext, err = msg.Encrypt([]*openpgp.Entity{privateKey}, privateKey)
if err != nil { if err != nil {
@ -282,6 +289,7 @@ func (s *session) Data(r io.Reader) error {
} }
// Create and send the outgoing message // Create and send the outgoing message
log.Println("sending message")
outgoing := &protonmail.OutgoingMessage{ID: msg.ID} outgoing := &protonmail.OutgoingMessage{ID: msg.ID}
if len(plaintextRecipients) > 0 { if len(plaintextRecipients) > 0 {
@ -376,6 +384,8 @@ func (be *backend) Login(_ *smtp.ConnectionState, username, password string) (sm
// TODO: decrypt private keys in u.Addresses // TODO: decrypt private keys in u.Addresses
log.Println("%q logged in", username)
return &session{c, u, privateKeys, addrs}, nil return &session{c, u, privateKeys, addrs}, nil
} }