-
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flip title and message if message is empty
- Loading branch information
Philipp Heckel
committed
Dec 28, 2021
1 parent
113053a
commit 04719f8
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,38 @@ Content-Type: text/html; charset="UTF-8" | |
require.Nil(t, session.Data(strings.NewReader(email))) | ||
} | ||
|
||
func TestSmtpBackend_MultipartNoBody(t *testing.T) { | ||
email := `MIME-Version: 1.0 | ||
Date: Tue, 28 Dec 2021 01:33:34 +0100 | ||
Message-ID: <[email protected]> | ||
Subject: This email has a subject but no body | ||
From: Phil <[email protected]> | ||
To: [email protected] | ||
Content-Type: multipart/alternative; boundary="000000000000bcf4a405d429f8d4" | ||
--000000000000bcf4a405d429f8d4 | ||
Content-Type: text/plain; charset="UTF-8" | ||
--000000000000bcf4a405d429f8d4 | ||
Content-Type: text/html; charset="UTF-8" | ||
<div dir="ltr"><br></div> | ||
--000000000000bcf4a405d429f8d4--` | ||
_, backend := newTestBackend(t, func(m *message) error { | ||
require.Equal(t, "emailtest", m.Topic) | ||
require.Equal(t, "", m.Title) // We flipped message and body | ||
require.Equal(t, "This email has a subject but no body", m.Message) | ||
return nil | ||
}) | ||
session, _ := backend.AnonymousLogin(nil) | ||
require.Nil(t, session.Mail("[email protected]", smtp.MailOptions{})) | ||
require.Nil(t, session.Rcpt("[email protected]")) | ||
require.Nil(t, session.Data(strings.NewReader(email))) | ||
} | ||
|
||
func TestSmtpBackend_Plaintext(t *testing.T) { | ||
email := `Date: Tue, 28 Dec 2021 00:30:10 +0100 | ||
Message-ID: <CAAvm79YP0C=Rt1N=KWmSUBB87KK2rRChmdzKqF1vCwMEUiVzLQ@mail.gmail.com> | ||
|