fix(GODT-2479): Ensure messages always have a text body part

Proton Backend requires that all messages have at least one text/plain
or text/html body part, even if it is empty.
This commit is contained in:
Leander Beernaert
2023-03-14 10:34:03 +01:00
parent 48274ee178
commit 8b33d56b59
4 changed files with 222 additions and 2 deletions

View File

@ -117,6 +117,10 @@ func (user *User) sendMail(authID string, from string, to []string, r io.Reader)
return fmt.Errorf("failed to get first key: %w", err)
}
// Ensure that there is always a text/html or text/plain body part. This is required by the API. If none
// exists and empty text part will be added.
parser.AttachEmptyTextPartIfNoneExists()
// If we have to attach the public key, do it now.
if settings.AttachPublicKey {
key, err := addrKR.GetKey(0)