Skip to content

Commit

Permalink
smtp: set ExternalID when creating draft
Browse files Browse the repository at this point in the history
Re-use the client's Message-Id header when creating a new draft.
This allows In-Reply-To to work as expected in subsequent messages.

Closes: #186
  • Loading branch information
emersion committed Jul 30, 2021
1 parent c6c1d6c commit b122ca8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,19 @@ func (s *session) Data(r io.Reader) error {
return errors.New("sender address key hasn't been decrypted")
}

msgID, err := mr.Header.MessageID()
if err != nil {
return fmt.Errorf("failed to parse Message-Id: %v", err)
}

msg := &protonmail.Message{
ToList: toPMAddressList(toList),
CCList: toPMAddressList(ccList),
BCCList: toPMAddressList(bccList),
Subject: subject,
Header: formatHeader(mr.Header),
AddressID: fromAddr.ID,
ToList: toPMAddressList(toList),
CCList: toPMAddressList(ccList),
BCCList: toPMAddressList(bccList),
Subject: subject,
Header: formatHeader(mr.Header),
AddressID: fromAddr.ID,
ExternalID: msgID,
Sender: &protonmail.MessageAddress{
Address: rawFrom.Address,
Name: rawFrom.Name,
Expand Down

0 comments on commit b122ca8

Please sign in to comment.